Search code examples
stringjenkinsgroovycoding-style

Jenkins - How to concatenate ${WORKSPACE} with a string literal?


In the below scripted pipeline code(groovy syntax):

ws('/app/jenkins/workspace/abc/def/ghi'){
            sh './mvnw clean install
}

ws('/app/jenkins/workspace/abc/def/xyz'){
            sh './mvnw clean install
}

where

/app/jenkins/workspace/abc/def is ${WORKSPACE}

ghi & xyz are sub-folders within ${WORKSPACE}


How to concatenate ${WORKSPACE} with sub-folder ghi and store the value in someVar? to use the syntax ws(someVar){}


Solution

  • You can try ws("${WORKSPACE}/ghi"){ .... }

    Pay attention to use gstring substitution must be double quotes, single quote is a typical string