Reputation: 656
I'm trying to mount the workspace as a volume when using Jenkinsfile, but am getting an error that WORKSPACE does not exist as a binding.
pipeline {
agent {
dockerfile {
filename 'Dockerfile'
dir 'docker/build_env'
args "-v ${WORKSPACE}/source:/slate/source -v ${WORKSPACE}/build:/slate/build"
}
}
}
And the error is:
groovy.lang.MissingPropertyException: No such property: WORKSPACE for class: groovy.lang.Binding
I've also tried ${env.WORKSPACE} but this resolves as null and pwd() which resolved to a class name. I've previously used ${WORKSPACE} successfully before so I'm at a loss.
Please can someone help with what I'm doing wrong?
Thanks.
Upvotes: 4
Views: 5755
Reputation: 656
The answer is quotation marks. "-v ${WORKSPACE}/source:/slate/source -v ${WORKSPACE}/build:/slate/build" should be '-v ${WORKSPACE}/source:/slate/source -v ${WORKSPACE}/build:/slate/build'
Upvotes: 3