Pass parmas from one stage to anohter

14 views
Skip to first unread message

GS_L

unread,
Mar 6, 2017, 5:09:17 AM3/6/17
to Jenkins Users
Hi
I read environment variables from file. 
The following works, but there is a code duplication:
(
. ${JENKINS_HOME}/jobs/credentials.sh > /dev/null 2>&1
curl -u $GITHUB_USERNAME:$GITHUB_PASSWORD https://raw.githubusercontent.com/cloudify-cosmo/cloudify-premium/master/packages-urls/common_build_env.sh -o ./common_build_env.sh
. $PWD/common_build_env.sh
)
Where can I read the file so both of the stages will recognize the variables?

pipeline {

agent { label 'web-ui-04888827' }

stage('Pack') {
steps {
dir('cloudify-stage') {
sh 'sudo npm run zip'
}
sh '''. ${JENKINS_HOME}/jobs/credentials.sh > /dev/null 2>&1
curl -u $GITHUB_USERNAME:$GITHUB_PASSWORD https://raw.githubusercontent.com/cloudify-cosmo/cloudify-premium/master/packages-urls/common_build_env.sh -o ./common_build_env.sh
. $PWD/common_build_env.sh
mv cloudify-stage/stage.tar.gz cloudify-stage-$VERSION-$PRERELEASE.tgz'''

}
}

stage('Upload package to S3') {
steps {
sh '''set +x
. ${JENKINS_HOME}/jobs/credentials.sh > /dev/null 2>&1
curl -u $GITHUB_USERNAME:$GITHUB_PASSWORD https://raw.githubusercontent.com/cloudify-cosmo/cloudify-premium/master/packages-urls/common_build_env.sh -o ./common_build_env.sh
. $PWD/common_build_env.sh
s3cmd put --access_key=${AWS_ACCESS_KEY_ID_UPLOAD_TEMP} --secret_key=${AWS_ACCESS_KEY_UPLOAD_TEMP} --human-readable-sizes --acl-public \\
cloudify-stage-$VERSION-$PRERELEASE.tgz \\
s3://$AWS_S3_BUCKET/$AWS_S3_PATH/'''
}
}
}
Reply all
Reply to author
Forward
0 new messages