Skip to content

Instantly share code, notes, and snippets.

@patoarvizu
Last active December 19, 2015 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patoarvizu/5888008 to your computer and use it in GitHub Desktop.
Save patoarvizu/5888008 to your computer and use it in GitHub Desktop.
Iterate over a file called branches (that should contain a list of branches to be built, one in each line) and triggers another Jenkins job via the REST API and authenticating with the API Token. It pulls the missing revisions from ALL branches as a final step.
for branch in $(cat branches)
do
echo "---------------"
echo "Branch: $branch"
json="{\"parameter\": [{\"name\": \"branch\", \"value\": \"$branch\"}]}"
curl -F json="$json" -u $1:$2 $JENKINS_URL/job/$2/build?token=$4
done
hg pull -u
@patoarvizu
Copy link
Author

Invocation:

JobForEachBranch.sh jenkinsUsername jenkinsAPIToken targetJob targetJobToken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment