PureDevOps Community

Jenkins how to pass parameters from Pipeline job to another job

From the Calling Job:

pipeline {
    agent any

    parameters {
        string(defaultValue: "123", description: 'This is a parameter', name: 'PARAMETER01')
    }

    stages {
        stage('Start'){
            steps{
                    build job: 'ANOTHER_JOB_NAME', wait: false, parameters: [string(name: 'HELLO', value: String.valueOf(PARAMETER01))]
            }
        }
    }
}

On the target job

pipeline {
    agent any

    parameters {
        string(defaultValue: "", description: 'K', name: 'HELLO')
    }

    stages {
        stage('PrintParameter'){
            steps{
                sh 'echo ${HELLO}'
            }
        }
    }
}