Skip to content

Instantly share code, notes, and snippets.

@slint
Last active April 24, 2018 13:32
Show Gist options
  • Save slint/bc64e464ae49396226bd952ec668bedf to your computer and use it in GitHub Desktop.
Save slint/bc64e464ae49396226bd952ec668bedf to your computer and use it in GitHub Desktop.
#!/bin/bash
# TODO: Parse arguments...
GITLAB_PIPELINE_TRIGGER_URL=https://gitlab.cern.ch/api/v4/projects/33605/trigger/pipeline
SERVICE_NAME=asclepias
if [ ! -z $BRANCH_NAME ]; then
# run commands to checkout a branch
echo "Checkout branch ${BRANCH_NAME}"
git checkout $BRANCH_NAME;
elif [ ! -z $COMMIT_ID ]; then
# run commands to checkout a commit
echo "Checkout commit ${COMMIT_ID}"
git checkout $COMMIT_ID;
elif [ ! -z $TAG_NAME ]; then
# run commands to checkout a tag
echo "Checkout tag ${TAG_NAME}"
git checkout tags/$TAG_NAME;
elif [ ! -z $PR_ID ]; then
# run commands to checkout a pr
echo "Checkout PR #${PR_ID}"
git fetch origin pull/$PR_ID/head:$PR_ID
git checkout $PR_ID;
fi
# TODO: Insert your GitLab Pipeline Trigger URL here:
curl -X POST \
-F token=${YOUR_TRIGGER_TOKEN} \
-F ref=${SERVICE_NAME} \
-F "variables[GIT_REF]={}"
https://gitlab.cern.ch/api/v4/projects/39286/trigger/pipeline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment