注: この質問は、同じシナリオを提示する一連の質問の一部です。シリーズの各質問には、指定された目標を達成できる独自のソリューションが含まれています。問題セットには、複数の正解があるものもあれば、正解がないものもあります。
このセクションの質問に回答すると、その質問に戻ることはできなくなります。そのため、これらの質問はレビュー画面に表示されません。
Azure Pipelines を使用して、React.js アプリケーションをビルドおよびテストします。
単一のジョブを持つパイプラインがあります。
パイプラインを実行するたびに、npm から JavaScript パッケージをインストールするのに約 5 分かかることがわかりました。
パイプラインの実行時間を短縮するソリューションを推奨する必要があります。
解決策: パイプライン成果物を使用することをお勧めします。
これは目標を満たしていますか?
正解:B
Pipeline artifacts are a way to persist build outputs, test results, and other files generated during a pipeline run. They allow you to share data between stages, jobs, and pipelines, and to persist data for longer than the lifetime of a pipeline run. While artifacts can be useful for sharing data between pipeline runs and reducing the time required to download dependencies, they are not a solution for reducing the time required to install JavaScript packages from npm during a pipeline run.
The solution of reducing the pipeline execution time could be achieved by using package caching, which allows you to store and reuse npm packages from previous pipeline runs. There are several package caching options available for Azure Pipelines, including the npm task, the npm cache task, and the npm ci task. All of these options allow you to configure caching for your npm packages, which can significantly reduce the time required to install packages during subsequent pipeline runs.
Another solution could be using a dedicated agent that has those packages already installed, this way the pipeline doesn't have to install them again.
You can find more information on package caching by following this link https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/package/npm-cache?view=azure-devops