Answers: <p>The issue was missing comma between <code>build job</code> and <code>parameters</code>. Below is the correct syntax:</p>
  
  <pre><code>...
                      build job: 'run-on-single-repo',
                      parameters:
  
  ... 
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2022-05-27T02:17:10.563Z
Answers: Is `run-on-single-repo.groovy` the Jenkinsfile equivalent for pipelineB? How do I pass in `build job: '<YOUR_PATH_HERE>'` command, if it is stored on a relative path?
Answers: bot
Answers: CC BY-SA 4.0
Answers: 2020-05-21T15:21:07.180Z
Answers: 2020-05-21T15:21:07.180Z
Answers: rokpoto.com
Body: <p>I passed params to pipeline B and set the environment variables from parameters. However, <code>"${params.URL}"</code> is evaluated as null.</p>
  
  <p>Pipeline A is declared in <code>Jenkinsfile</code>:</p>
  
  <pre><code>pipeline {
      agent any    
  
      stages {
          stage('Run on all repos') {
  
              steps { 
                  script {
                      sh 'ls'
                      build job: 'run-on-single-repo'
                      parameters:
                              [string(name:'URL', value:'val')]
  }}}}}
  </code></pre>
  
  <p>Pipeline B is declared in <code>run-on-single-repo.groovy</code>:</p>
  
  <pre><code>pipeline {
      agent any
  
      stages {
  
          stage('Find missing dependencies') {
  
              environment {
  
                  URL = "${params.URL}"
  
              }
  
              steps { 
  ...
  </code></pre>
  
  <p>Both pipelines are configured in Jenkins as 'Pipeline script from SCM' and work.</p>
  
  <p>How to pass environment variables from pipeline job A to pipeline job B?</p>
  
Tags: <jenkins><jenkins-pipeline><jenkinsfile><environment-variables>
Title: Pass environment variables from pipeline job A to pipeline job B
UserDisplayName: rokpoto.com
ThreadText: # Pass environment variables from pipeline job A to pipeline job B
  
  (Asked by: username_0 on 2020-05-21)
  
  I passed params to pipeline B and set the environment variables from parameters. However, `"${params.URL}"` is evaluated as null.
  
  Pipeline A is declared in `Jenkinsfile`:
  
  ```
  pipeline {
      agent any    
  
      stages {
          stage('Run on all repos') {
  
              steps { 
                  script {
                      sh 'ls'
                      build job: 'run-on-single-repo'
                      parameters:
                              [string(name:'URL', value:'val')]
  }}}}}
  
  ```
  
  Pipeline B is declared in `run-on-single-repo.groovy`:
  
  ```
  pipeline {
      agent any
  
      stages {
  
          stage('Find missing dependencies') {
  
              environment {
  
                  URL = "${params.URL}"
  
              }
  
              steps { 
  ...
  
  ```
  
  Both pipelines are configured in Jenkins as 'Pipeline script from SCM' and work.
  
  How to pass environment variables from pipeline job A to pipeline job B?
  
  **Tags:** jenkins, jenkins-pipeline, jenkinsfile, environment-variables
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-05-21. Score: 2
  
  The issue was missing comma between `build job` and `parameters`. Below is the correct syntax:
  
  ```
  ...
                      build job: 'run-on-single-repo',
                      parameters:
  
  ... 
  
  ```
  
  > **Comments:**
  > **username_1**: Is `run-on-single-repo.groovy` the Jenkinsfile equivalent for pipelineB? How do I pass in `build job: '<YOUR_PATH_HERE>'` command, if it is stored on a relative path?  
  
  ---
  
  