In an Azure DevOps pipeline after downloading an artifact from a previous stage
like this:
- download: 'current'
artifact: my_artifact
I want to reuse it in the Dockerfile
of this Docker build task:
- task: Docker@2
displayName: Build
inputs:
command: build
containerRegistry: myConnection
repository: myRepository
like this:
COPY *.whl /myDir/
After the COPY
command the target directory is still empty. Where are the files from the artifact and how do I copy them in the Dockerfile?
The solution is to copy the artifact from where it is downloaded to ($(Pipeline.Workspace)/my_artifact
) to the PATH
directory, of the build
command ($(Build.SourcesDirectory)
):
- bash: cp $(Pipeline.Workspace)/my_artifact/*.whl $(Build.SourcesDirectory)
Alternatively use the CopyFiles command:
- task: CopyFiles@2
inputs:
sourceFolder: '$(Pipeline.Workspace)/my_artifact'
contents: '*.whl'
targetFolder: $(Build.SourcesDirectory)