I'm developing a Jenkins pipeline for a PHP project. Since I want to run the most of the steps from the project's root directory, I set the customWorkspace:
pipeline {
agent {
node {
label 'devvm-slave-01'
customWorkspace '/path/to/my/project'
}
}
stages {
stage('build') {
steps {
sh 'pwd'
...
}
}
}
}
It's working fine, but I don't like, that the path is hard-coded in the Jenkinsfile.
So I tried to solve this by using parameters:

The problem is: I haven't found a way to access parameters in the block pipeline.agent.node. I can read and handle them in the pipeline.stages.stage.steps sections. But not in the node block.
Is it possible / How to access Jenkins project parameters in the node section of the Jenkinsfile?
You can pass the parameter instead of hard-coded value for
customWorkspacelike this: