2

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?

1

The issue was missing comma between build job and parameters. Below is the correct syntax:

...
                    build job: 'run-on-single-repo',
                    parameters:

... 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.