I have Upstream job A, passing "workspace" parameter to upstream job A. So, if job A triggers job B, it should use the job A specified workspace. The job B also needs to run independently, in that case it should use its own workspace.
In job B, I have specified string parameter name UPWORKSPACE and default value "unspecified", which is for reading the upstream job workspace parameter.
Job A:
agent {
stages {
agent
{ label 'test' }
stages
{
stage ('Invoke_pipelineA') {
steps {
build job: '/Job B', parameters: [
string(name: 'UPWorkspace', value: "${env.WORKSPACE}") ], wait: true
}
}
job B: This project is parameterized: String Parameter Name: UPWorkspace Default Value : notspecified.
pipeline {
agent none
stages {
stage("checkout ") {
agent {
node{
label "test"
customWorkspace "${UPWorkspace}"
}
}
steps {
echo "WORKSPACE: ${paramWorkspace}"
}
}
}
when Job A, triggers job B , its working fine, i could able to use custom workspace path, But if Job run independently i to tell job B to use normal workspace ?
Ideal solution would be if i am able to specify default value: env.WORKSPACE , in Job B, its perfect, but seems its not working.
some thing like this might be helpful, but i can't make it work in pipeline.
if (params.UPWORKSPACE != "notspecified") //use custom workspace when
default is not "notspecified"
{ customWorkspace "${UPWORKSPACE}"
}
Any help is appreciated. thanks!