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>
# 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
}