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