Last active
September 26, 2016 01:18
-
-
Save HokieGeek/ffbcebc81ee0313f18a3f4de55590502 to your computer and use it in GitHub Desktop.
Jenkins scripts for work
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branch=$1 | |
./jenkins-trigger-job.sh \ | |
'ApiTest' \ | |
"BRANCH:${branch}" \ | |
"IMAGE_ID:$(echo $branch | tr '[:upper:]' '[:lower:]')" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
job_name=$1 | |
shift | |
declare -a parameters | |
while (( $# > 0 )); do | |
parameters+=('{"name":"'"${1%%:*}"'","value":"'"${1##*:}"'"},') | |
shift | |
done | |
server="localhost:8888" | |
user=$(whoami) | |
crumb_file=/tmp/jenkins-crumb-${user} | |
if [ ! -f ${crumb_file} ]; then | |
curl --user ${user} --output ${crumb_file} "http://${server}/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,%22:%22,//crumb)" | |
fi | |
curl -X POST \ | |
-H $(cat $crumb_file) \ | |
${server}/job/${job_name}/build \ | |
--user ${user} \ | |
--data token=TRIGGER \ | |
--data-urlencode json='{"parameter": ['"${parameters[*]}"']}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
branch=${1##*/} | |
job_name="AIC-Releases-Watcher-${branch}" | |
server="molly:8080" | |
user=aperez | |
crumb_file=/tmp/jenkins-crumb-${user} | |
if [ ! -f ${crumb_file} ]; then | |
echo "Creating Jenkins crumb" | |
echo "enter password for ${user}:" | |
curl --user ${user} --output ${crumb_file} "http://${server}/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,%22:%22,//crumb)" | |
fi | |
echo "Triggering Jenkins project" | |
echo "enter password for ${user}:" | |
curl -X POST \ | |
-H $(cat ${crumb_file}) \ | |
${server}/job/${job_name}/build \ | |
--user ${user} \ | |
--data token=TRIGGER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment