I have an azure devops pipeline that publishes output,
pool:
vmImage: 'windows-latest'
steps:
- script: |
dotnet restore
dotnet build --configuration Release
- task: DotNetCoreCLI@2
inputs:
command: publish
arguments: '--configuration Release --output publish_output'
projects: 'MyProject/*.csproj'
publishWebProjects: false
modifyOutputPath: false
zipAfterPublish: false
- task: ArchiveFiles@2
displayName: "Archive files"
inputs:
rootFolderOrFile: "$(System.DefaultWorkingDirectory)/publish_output"
includeRootFolder: false
archiveFile: "$(System.DefaultWorkingDirectory)/myapp.zip"
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/myapp.zip'
artifactName: 'myapp'
and this works.
Another release pipeline should use the artifact generated by build,
trigger:
- main
variables:
azureSubscription: MySubscription
appName: myAppName
vmImageName: 'ubuntu-latest'
steps:
- task: DownloadBuildArtifacts@1
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'myapp'
downloadPath: '$(Build.ArtifactsDirectory)'
- task: AzureFunctionApp@1 # Add this at the end of your file
inputs:
azureSubscription: $(azureSubscription)
appType: functionApp # default is functionApp
appName: $(appName)
package: $(Build.ArtifactsDirectory)/**/*.zip
but this fails already in the DownloadBuildArtifacts task with error:
##[error]Artifact myapp was not found for build xy.
I can see in the log that the artifact is placed in some folder,
Upload 'D:a1smyapp.zip' to file container: '#/29596927/myapp'
but there is no info in which location the DownloadBuildArtifacts task is searching for the artifact (at least I did not find it even with analytics enabled in the pipeline run). Should I replace ‘Build.ArtifactsDirectory’ or is something wrong at another place?
2
Answers
You have to define your resources to that other build pipeline before or after the variables:
Then you can use the reference name in a download or checkout step:
From your YAML sample, the cause of the issue is that you need to download the artifacts from Build Pipeline, but in release pipeline, you add the DownloadBuildArtifacts task to download the current release pipeline artifacts.
Since the build artifacts doesn’t exist in release pipeline, it will cause the issue.
To solve this issue, you need to modify the DownloadBuildArtifacts task definition to download the build pipeline artifacts.
For example:
In this case, it will download the artifacts of Build Pipeline.
For more detailed info, you can refer to the doc: DownloadBuildArtifacts@1