patternMinor
Pass environment variables from pipeline job A to pipeline job B
Viewed 0 times
passenvironmentvariablesfromjobpipeline
Problem
I passed params to pipeline B and set the environment variables from parameters. However,
Pipeline A is declared in
Pipeline B is declared in
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?
"${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?
Solution
The issue was missing comma between
build job and parameters. Below is the correct syntax:...
build job: 'run-on-single-repo',
parameters:
...Code Snippets
...
build job: 'run-on-single-repo',
parameters:
...Context
StackExchange DevOps Q#11660, answer score: 2
Revisions (0)
No revisions yet.