I have a monorepo setup where I am trying to dispatch service Jenkinsfile from root JenkinsFile The structure looks like this:
Monorepo
- Jenkinsfile (at root)
- services
- Jenkinsfile (services Jenkinsfile)
- Service A
- src/
- Service B
- src/
Service Jenkinsfile is triggered from root Jenkinsfile.
These env variables are working fine in root jenkinsfile but they are giving null values in service jenkinsfile.
stage('Echo env') {
echo "Branch_name=${env.BRANCH_NAME}, PR_Branch_change=${env.CHANGE_BRANCH}, PR_Key=${env.CHANGE_ID}, PR_Base=${env.CHANGE_TARGET}, Key=$CHANGE_ID, branch=$CHANGE_BRANCH, base=$CHANGE_TARGET"
} // Stage is same in both the jenkinsfile
In service jenkinsfile either gives error:
or Print
Null
values
Is there any way to import or reference the env variables from another (root) Jenkinsfile