I'm trying to pass the $(Build.ArtifactStagingDirectory)
variable to a dockerfile using docker task like this:
- task: Docker@2
displayName: "Create docker image"
inputs:
command: 'build'
Dockerfile: '**/Dockerfile.publish'
arguments: '--build-arg APP=$(Build.ArtifactStagingDirectory)/Api'
But this fails because the path is in Windows style (like C:\agent\bla\
)
What would be the best solution here?
It appears you're using Windows self-hosted agent, and would like a linux POSIX path instead of windows path.
You can add a pre task, convert the path:
- bash: |
# Convert the path to POSIX format
posix_path=$(echo "$(Build.ArtifactStagingDirectory)" | sed -e 's/\\/\//g' -e 's/:\([^/]\)/\1/g')
echo $posix_path
echo "##vso[task.setvariable variable=linuxposix_path;]$posix_path"
- task: Docker@2
displayName: "Create docker image"
inputs:
command: 'build'
Dockerfile: '**/Dockerfile.publish'
arguments: '--build-arg APP=$(linuxposix_path)/Api'