Reputation: 755
Scenario:
Approach:
displayName: "Artifacts - download"
inputs:
packageType: 'npm'
feed: '38a52be4-9352-453e-af97-5c3b448652f0/38a52be4-9352-453e-af97-5c3b448652f0'
view: '070e33c7-f5c8-4561-8186-5c3b448652f0'
definition: '1f32cfbf-1427-4b27-8476-5c3b448652f0'
version: '1.0.1'
downloadPath: '$(System.ArtifactsDirectory)'
This sort of works, but it requires either to specify a hard-coded version inside the yaml-definition or else a wildcard "*" (latest version). Ideally, the version could be specified at runtime via the "Run Pipeline"-dialog. However, this requires for the package to be configured as a resource (Alt. 2)
According to the docs, there are number of possible resources: pipelines, builds, repositories, containers, packages and webhooks. In this case, "packages" resource seems approriate.
resources:
packages:
- package: contoso
type: npm
connection: pat-contoso
name: yourname/contoso
version: 7.130.88
trigger: true
However, the docs are lacking, only providing one example for GitHub packages.
I can't find any example, specifically for an "Azure Artifacts" package.
Who can share a working "package"-configuration, specifically for Azure Artifacts?
Upvotes: 3
Views: 1273
Reputation: 40533
You can use runtime parameters with your first option
parameters:
- name: packageVersion
displayName: Package version
type: string
default: '1.0.1'
trigger: none
jobs:
- job: Deploy
displayName: Deploy
steps:
- task: DownloadPackage@1
displayName: "Artifacts - download"
inputs:
packageType: 'npm'
feed: '38a52be4-9352-453e-af97-5c3b448652f0/38a52be4-9352-453e-af97-5c3b448652f0'
view: '070e33c7-f5c8-4561-8186-5c3b448652f0'
definition: '1f32cfbf-1427-4b27-8476-5c3b448652f0'
version: '${{ parameters.packageVersion }}'
downloadPath: '$(System.ArtifactsDirectory)'
And I'm afraid that you won't be able to combine this with resource as it can't support any way of templates/variables/parameters.
Upvotes: 1
Reputation: 28086
As Krzysztof suggests, the Runtime parameters should work for the version could be specified at runtime via the Run Pipeline -dialog
. And you may need to add extract: false
if you want to download the package archive.
I can't find any example, specifically for an "Azure Artifacts" package.
For now it's not supported for Azure Artifact Npm package, this document has stated that Resources: packages
option is only for Nuget/Npm github packages.
Upvotes: 1