Exporting evironment variables from Groovy script doesn't work

80 views
Skip to first unread message

chni...@gmail.com

unread,
May 30, 2016, 4:18:55 AM5/30/16
to Jenkins Users
We are currently using Jenkins version 2.7.
After upgrading from 1.647, we have the problem that environment variables created in a Groovy script are not exported and visible in a following shell script.
The projects are Maven-based.

System Groovy script:

// This script will set the artifact version to the environment variables "ARTIFACT_VERSION" and "SHORT_ARTIFACT_VERSION"

import hudson.model.*
import hudson.util.*

def currentBuild = Thread.currentThread()?.executable

def artifactVer = currentBuild.parent.modules.find{true}.version;
def artifactVerAction = new ParametersAction(new StringParameterValue("ARTIFACT_VERSION", artifactVer))
currentBuild?.addAction(artifactVerAction)

def shortArtifactVer = artifactVer - '-SNAPSHOT';
def shortArtifactVerAction = new ParametersAction(new StringParameterValue("SHORT_ARTIFACT_VERSION", shortArtifactVer))
currentBuild?.addAction(shortArtifactVerAction)


Shell script:

mkdir -p /home/rolotec/3rdparty/iD2ds/$ARTIFACT_VERSION
cp -u $WORKSPACE/target/tkfserver-$ARTIFACT_VERSION.jar /home/rolotec/3rdparty/iD2ds/$ARTIFACT_VERSION/


The problems started after an upgrade to Jenkins 2.5. Then also $WORKSPACE had no value. An upgrade to 2.6 seemed to solve that, but our own environment variables are still lost using 2.7.

Kind regards,
Niklas Oscarsson

Daniel Beck

unread,
May 31, 2016, 7:04:01 AM5/31/16
to jenkins...@googlegroups.com

> On 30.05.2016, at 10:18, chni...@gmail.com wrote:
>
> We are currently using Jenkins version 2.7.
> After upgrading from 1.647, we have the problem that environment variables created in a Groovy script are not exported and visible in a following shell script.
> The projects are Maven-based.

https://wiki.jenkins-ci.org/display/SECURITY/Jenkins+Security+Advisory+2016-05-11

Reply all
Reply to author
Forward
0 new messages