3

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?

rokpoto.com
  • 266
  • 3
  • 9

1 Answers1

2

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

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

... 
rokpoto.com
  • 266
  • 3
  • 9