Set AGENT_ROOT_FOLDER as env var.

This commit is contained in:
Manuele Simi 2019-10-10 12:32:40 -04:00
parent b90b80ae42
commit 375ff075e1
1 changed files with 8 additions and 5 deletions

13
Jenkinsfile vendored
View File

@ -69,6 +69,8 @@ pipeline {
// see https://jenkins.io/doc/book/pipeline/syntax/#environment
environment {
JOB_OPTIONS = "${options}"
AGENT_ROOT_FOLDER = "${agent_root_folder}"
MAVEN_SETTINGS_FILE = "${maven_settings_file}"
MAVEN_LOCAL_REPO = "${agent_root_folder}/${maven_local_repo_path}"
GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}"
PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}"
@ -94,8 +96,8 @@ pipeline {
rm -rf $MAVEN_LOCAL_REPO
mkdir -p $MAVEN_LOCAL_REPO
// default the selected maven settings
mv "${agent_root_folder}/settings.xml" "${agent_root_folder}/settings.${PIPELINE_BUILD_NUMBER}"
cp "${agent_root_folder}/${maven_settings_file}" "${agent_root_folder}/settings.xml"
mv "${AGENT_ROOT_FOLDER}/settings.xml" "${AGENT_ROOT_FOLDER}/settings.${PIPELINE_BUILD_NUMBER}"
cp "${AGENT_ROOT_FOLDER}/${MAVEN_SETTINGS_FILE}" "${AGENT_ROOT_FOLDER}/settings.xml"
echo "Done with local repository"
'''
}
@ -195,12 +197,13 @@ pipeline {
// post-build actions
post {
always {
echo 'The default maven settings have been restored'
steps {
script {
sh '''
mv "${agent_root_folder}/settings.${PIPELINE_BUILD_NUMBER}" "${agent_root_folder}/settings.xml"
mv "${AGENT_ROOT_FOLDER}/settings.${PIPELINE_BUILD_NUMBER}" "${AGENT_ROOT_FOLDER}/settings.xml"
'''
}
echo 'The default maven settings have been restored'
}
success {
echo 'The pipeline worked!'