Use Ref as Revision 45/10145/3 v9.0.0
authorbeierlm <mark.beierl@canonical.com>
Fri, 18 Dec 2020 12:30:48 +0000 (07:30 -0500)
committerbeierlm <mark.beierl@canonical.com>
Fri, 18 Dec 2020 13:00:59 +0000 (08:00 -0500)
Change to use the short ref for the proposed revision instead
of Gerrit Ref Spec.  This allows the job to succeed even if
there is no refspec, such as when a new branch is created.

Change-Id: Icec5615f8e01f33507dc87765a240a3de2489e09
Signed-off-by: beierlm <mark.beierl@canonical.com>
jenkins/ci-pipelines/ci_stage_2.groovy
jenkins/ci-pipelines/ci_stage_3.groovy

index 049763c..616f569 100644 (file)
@@ -88,7 +88,9 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa
 
             REV=""
             if ( !JOB_NAME.contains('merge') ) {
-                REV="/"+"${GERRIT_REFSPEC}".replaceAll('/','-')
+                short_ref=sh(returnStdout: true,
+                    script: "git rev-parse --short HEAD").trim()
+                REV="/"+short_ref
             }
             channel="latest"
             if (BRANCH_NAME.startsWith("v")) {
index 541213b..de2aaac 100644 (file)
@@ -531,14 +531,14 @@ EOF"""
                                     "-w /build snapcore/snapcraft:stable /bin/bash -c " +
                                     "\"snapcraft login --with /snapcraft/config &>/dev/null && " +
                                     "snapcraft revisions $snap\" | " +
-                                    "grep \" $track\" | tail -1 | awk '{print \$1}'").trim()
+                                    "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
                                 track=channel+"beta\\*"
                                 beta_rev=sh(returnStdout: true,
                                     script: "sudo docker run -v ~/.snapcraft:/snapcraft -v ${WORKSPACE}:/build " +
                                     "-w /build snapcore/snapcraft:stable /bin/bash -c " +
                                     "\"snapcraft login --with /snapcraft/config &>/dev/null && " +
                                     "snapcraft revisions $snap\" | " +
-                                    "grep \" $track\" | tail -1 | awk '{print \$1}'").trim()
+                                    "grep \"$track\" | tail -1 | awk '{print \$1}'").trim()
 
                                 if ( edge_rev != beta_rev ) {
                                     print "Promoting $edge_rev to beta in place of $beta_rev"