{"id":57008,"date":"2019-07-24T08:00:44","date_gmt":"2019-07-24T16:00:44","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/devops\/?p=57008"},"modified":"2019-07-24T08:04:07","modified_gmt":"2019-07-24T16:04:07","slug":"caching-and-faster-artifacts-in-azure-pipelines","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/caching-and-faster-artifacts-in-azure-pipelines\/","title":{"rendered":"Caching and faster artifacts in Azure Pipelines"},"content":{"rendered":"<p>I&#8217;m excited to announce the public previews of pipeline caching and pipeline artifacts in <a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/devops\/pipelines\/\">Azure Pipelines<\/a>. Together, these technologies can make every run of your pipeline faster by accelerating the transfer of artifacts between jobs and stages, and by caching the results of common operations like package restores.<\/p>\n<h2>Pipeline caching<\/h2>\n<p>Pipeline caching introduces a new <code>CacheBeta<\/code> task that takes a path of files to cache and a cache key. A cache key can be the contents of a file (like a package lockfile), a string of your choice, or a combination of both.<\/p>\n<p>For example, to cache Node.js dependencies installed with Yarn:<\/p>\n<pre><code class=\"yaml\">steps:\n- task: NodeTool@0\n  inputs:\n    versionSpec: '10.x'\n  displayName: 'Install Node.js 10.x'\n\n- task: CacheBeta@0\n  inputs:\n    key: |\n      $(Agent.OS)\n      $(Build.SourcesDirectory)\/yarn.lock\n    path: $(Pipeline.Workspace)\/.cache\/yarn\n  displayName: 'Cache yarn'\n\n- script: yarn install\n<\/code><\/pre>\n<p>As we&#8217;ve implemented pipeline caching, we&#8217;ve learned that every tool behaves differently. So, we&#8217;re excited to release this preview and see the cache used in the wild. If you try out the cache and find it doesn&#8217;t improve the performance of the step you&#8217;re caching, we&#8217;d like to hear about it as an <a href=\"https:\/\/github.com\/microsoft\/azure-pipelines-tasks\/issues\/new?labels=Area:%20PipelineCaching\">issue on azure-pipelines-tasks<\/a>. If you can create a public repo and pipeline that we can fork to reproduce your issue, all the better. We&#8217;ll be listening to these issues and tuning the cache.<\/p>\n<p>We&#8217;ve already got some improvements, including <a href=\"https:\/\/github.com\/microsoft\/azure-pipelines-tasks\/issues\/10841\">preserving file attributes<\/a> and <a href=\"https:\/\/github.com\/microsoft\/azure-pipelines-tasks\/issues\/10842\">fallback keys<\/a>, that we&#8217;ll be shipping while the preview is running. We look forward to your ideas and feedback.<\/p>\n<p>There&#8217;s a possibility we&#8217;ll make breaking changes between v0 and v1 of the task, so we recommend <strong>not yet including the cache in production\/master branch CI builds.<\/strong><\/p>\n<p>Learn more about <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/caching\/index\">pipeline caching on docs.microsoft.com<\/a>.<\/p>\n<h2>Pipeline artifacts<\/h2>\n<p>Pipeline artifacts are the built-in way to move files between jobs and stages of your pipeline and to save files from your pipeline for later use. Pipeline artifacts intelligently deduplicate content and only upload net-new content to the server, which helps speed up repeated builds of the same repository.<\/p>\n<p>To use Pipeline artifacts, just use the <code>publish<\/code> and <code>download<\/code> YAML shortcuts, like this:<\/p>\n<pre><code class=\"yaml\">steps:\n- publish: bin\n  artifact: binaries\n<\/code><\/pre>\n<p>By default, all artifacts published by previous jobs are downloaded at the beginning of subsequent jobs, so it&#8217;s not necessary to add a download step. If you want to control this behavior, use the download shortcut, like this:<\/p>\n<pre><code class=\"yaml\">steps:\n- download: none\n<\/code><\/pre>\n<p>For most common use cases, the <code>publish<\/code> and <code>download<\/code> shortcuts are recommended. However, if you need more control over how your artifacts are downloaded, you can also use the <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/tasks\/utility\/download-pipeline-artifact\">Download Pipeline Artifact<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/tasks\/utility\/publish-pipeline-artifact\">Publish Pipeline Artifact<\/a> tasks directly.<\/p>\n<p>Learn more about <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/artifacts\/pipeline-artifacts\">pipeline artifacts on docs.microsoft.com<\/a>. And, if you run into issues, let us know on <a href=\"https:\/\/developercommunity.visualstudio.com\/spaces\/21\/index.html\">Developer Community<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m excited to announce the public previews of pipeline caching and pipeline artifacts in Azure Pipelines. Together, these technologies can make every run of your pipeline faster by accelerating the transfer of artifacts between jobs and stages, and by caching the results of common operations like package restores.<\/p>\n","protected":false},"author":734,"featured_media":57225,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[226,223],"tags":[],"class_list":["post-57008","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ci","category-package-management"],"acf":[],"blog_post_summary":"<p>I&#8217;m excited to announce the public previews of pipeline caching and pipeline artifacts in Azure Pipelines. Together, these technologies can make every run of your pipeline faster by accelerating the transfer of artifacts between jobs and stages, and by caching the results of common operations like package restores.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/57008","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/734"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=57008"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/57008\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/57225"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=57008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=57008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=57008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}