Hi,
as a simple test case, I created these two pipelines.
First, the "upstream pipeline":
pipeline {
agent {
label 'Linux-Test'
}
environment {
name = 'foo'
}
stages {
stage('Set environment') {
environment {
name = 'bar'
}
steps {
echo "name=${name}"
}
}
}
}
Second, the "downstream pipeline":
pipeline {
agent {
label 'Linux-Test'
}
triggers {
upstream(
upstreamProjects: "upstream-pipeline",
threshold: hudson.model.Result.SUCCESS
)
}
stages {
stage('print upstream environment') {
steps {
script {
echo currentBuild.rawBuild.getCause(Cause$UpstreamCause).getUpstreamRun().getEnvironment(TaskListener.NULL).toMapString()
}
}
}
}
}
Anyone?
Best regards
Stefan
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/c7050334228f44a382f82cfd69c6f965%40tk.de.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c77af83b4b0440f89c0e03fb7831de50%40tk.de.
Hi,
thanks for the suggestions.
Sidenote: This solution, using environment variables used to work and afaik, we didn't make any pipeline changes, related to this. Unfortunately I can't narrow down, since when exactly it broke.
I can confirm, that allowing undefined parameters (JENKINS-56875) does not help.
I realized, that the environment, returned by Run.getEnvironment() does not even contain my custom environment variables, when I call it on currentBuild.rawBuild.
So this issue is not even related to a upstream/downstream relation between two pipelines.
The getEnvironment() method simply seems to behave differently since…???
Here is my simplified example.
pipeline {
agent {
label 'Linux-Test'
}
environment {
name = 'foo'
}
stages {
stage('Set environment') {
environment {
name = 'bar'
}
steps {
echo "${currentBuild.rawBuild.getEnvironment(TaskListener.NULL)}"
}
}
}
}
environment (from console log):
[BUILD_DISPLAY_NAME:#5, BUILD_ID:5, BUILD_NUMBER:5, BUILD_TAG:jenkins-upstream-pipeline-5, BUILD_TIMESTAMP:2020-02-26_13-20-47, BUILD_URL:https://jenkins-test8080/job/upstream-pipeline/5/, CLASSPATH:, GIT_HOME:C:\ tools\git, HUDSON_HOME:c:\jenkins\jenkins-test, HUDSON_SERVER_COOKIE:662af83ef93bf80d, HUDSON_URL:https://jenkins-test:8080/, JDK_18_LATEST_X64:C:\SPU\ext64\jdk1.8.0_112, jenkins.slaves.DefaultJnlpSlaveReceiver.disableStrictVerification:true, JENKINS_HOME:c:\jenkins\jenkins-test, JENKINS_SERVER_COOKIE:662af83ef93bf80d, JENKINS_URL:https://jenkins-test.dst.tk-inline.net:8080/, JOB_BASE_NAME:upstream-pipeline, JOB_DISPLAY_URL:https://jenkins-test.dst.tk-inline.net:8080/job/upstream-pipeline/display/redirect, JOB_NAME:upstream-pipeline, JOB_URL:https://jenkins-test:8080/job/upstream-pipeline/, RUN_CHANGES_DISPLAY_URL:https://jenkins-test:8080/job/upstream-pipeline/5/display/redirect?page=changes, RUN_DISPLAY_URL:https://jenkins-test:8080/job/upstream-pipeline/5/display/redirect]
Still hoping, that there is a way to get the complete environment…
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtGixiNpgOKp4XDaaA2raaKFj82GdA1OouKyFLmGDtyyZw%40mail.gmail.com.