0

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

Printing root jenkinsfile env variables In service jenkinsfile either gives error: Error or Print Null values null values Is there any way to import or reference the env variables from another (root) Jenkinsfile

Rajat jain
  • 1,715
  • 3
  • 12
  • 21

1 Answers1

0

Finally, I was able to get env variables values printed from parent jenkinsfile to child jenkinsfile

Here is the post I went through and somehow it helped me getting end result

Pass environment variables from parent job to child job Jenkins pipeline

Rajat jain
  • 1,715
  • 3
  • 12
  • 21