21041: Improves the sync() function so that it can push code from HEAD. 21041-installer-from-HEAD
authorLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 3 Nov 2023 15:10:43 +0000 (12:10 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 3 Nov 2023 15:10:43 +0000 (12:10 -0300)
When running the installer from a Jenkins pipeline, the checked out code
may not be from a specific branch, so we need to take care of this special
case when pushing the code to the bare repositories on the nodes.

Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

tools/salt-install/installer.sh

index bb57666da6c02eaf1fece49dd90c41b1a3cc06c4..27feffa2d209210d385b7f5534d882fb919e05f2 100755 (executable)
@@ -103,8 +103,15 @@ sync() {
     # from that.
 
     $SSH $DEPLOY_USER@$NODE git init --bare --shared=0600 ${GITTARGET}.git
-    $GIT push $NODE $BRANCH
-    $SSH $DEPLOY_USER@$NODE "umask 0077 && git clone -s ${GITTARGET}.git ${GITTARGET} && git -C ${GITTARGET} checkout ${BRANCH}"
+    if [[ "$BRANCH" == "HEAD" ]]; then
+      # When deploying from an individual commit instead of a branch. This can
+      # happen when deploying from a Jenkins pipeline.
+      $GIT push $NODE HEAD:refs/heads/HEAD
+      $SSH $DEPLOY_USER@$NODE "umask 0077 && git clone -s ${GITTARGET}.git ${GITTARGET} && git -C ${GITTARGET} checkout remotes/origin/HEAD"
+    else
+      $GIT push $NODE $BRANCH
+      $SSH $DEPLOY_USER@$NODE "umask 0077 && git clone -s ${GITTARGET}.git ${GITTARGET} && git -C ${GITTARGET} checkout ${BRANCH}"
+    fi
   fi
 }