def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifactory_server,docker_args="",do_stage_4=false) {
println("do_stage_3= ${do_stage_3}")
ci_helper = load "devops/jenkins/ci-pipelines/ci_helper.groovy"
+ def isMergeJob = JOB_NAME.contains('merge')
stage('Prepare') {
sh 'env'
}
stage('License Scan') {
- if (!JOB_NAME.contains('merge')) {
+ if (!isMergeJob) {
sh "devops/tools/license_scan.sh"
}
else {
stage('Release Note Check') {
if (fileExists('devops-stages/stage-releasenote.sh')) {
- if (!JOB_NAME.contains('merge')) {
+ if (!sMergeJob) {
sh "devops-stages/stage-releasenote.sh"
}
else {
sh "sudo rm -rf ${WORKSPACE}/stage/ ${WORKSPACE}/parts/ ${WORKSPACE}/prime/"
REV=""
- if ( !JOB_NAME.contains('merge') ) {
+ if ( ! isMergeJob ) {
REV="/"+"${GERRIT_REFSPEC}".replaceAll('/','-')
}
channel="latest"
def directory = charmPath
CHECK_CHANGES = "git diff --name-only origin/$GERRIT_BRANCH -- $directory |wc -l"
charmsChanged = sh(returnStdout:true, script: CHECK_CHANGES).trim()
- if (charmsChanged != "0") {
+ if (charmsChanged != "0" || isMergeJob) {
println("$directory has changes, rebuilding")
parallelSteps[directory] = {
try {
dir("${directory}") {
try {
- sh "charmcraft pack --format json --verbosity brief 1> pack.json 2> pack-stderr.log"
+ sh "charmcraft pack --force --format json --verbosity brief 1> pack.json 2> pack-stderr.log"
} catch (Exception e) {
sh "cat pack-stderr.log"
throw e
println("Uploading $resourceName")
sh "charmcraft upload --format json --verbosity brief $resourceName 1> upload.json 2> upload-stderr.log"
} catch (Exception e) {
+ def errorMessage = sh(
+ returnStdout: true,
+ script: 'cat upload.json | jq -r ".errors[0].message" | grep -v null').trim()
+ if (errorMessage.contains("already exists")) {
+ println("No changes, skipping upload")
+ return 0
+ }
sh "cat upload-stderr.log"
throw e
}