Created
November 11, 2016 17:39
-
-
Save scorpp/4f40dfab53c93b574b6c5cce4066032e to your computer and use it in GitHub Desktop.
Jenkins script to upgrade a service on Rancher
This file contains 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
test -f JSON.sh || curl -O https://raw.githubusercontent.com/dominictarr/JSON.sh/master/JSON.sh | |
eval $(sed 's/^/MY_/' build.info) | |
ORIG_LAUNCH_CONFIG=$(cat my-app-service.json | bash ./JSON.sh | grep -F '["launchConfig"]' | sed -e 's/[^{]*//') | |
NEW_LAUNGH_CONFIG=$(echo $ORIG_LAUNCH_CONFIG |\ | |
sed "s/\(\"imageUuid\"\):\"[^\"]*\"/\1:\"docker:my-image:${MY_BUILD_NUMBER}\"/") | |
echo $NEW_LAUNGH_CONFIG |\ | |
xargs -d\\n -i_-_ curl -v -u "RANCHER_KEY:RANCHER_SECRET" \ | |
-X POST -H 'Content-Type: application/json' \ | |
-d '{"inServiceStrategy":{"launchConfig": _-_ }}' \ | |
http://rancher-server/v1/services/1s10?action=upgrade | |
sleep 60 | |
# confirm upgrade | |
curl -v -u "RANCHER_KEY:RANCHER_SECRET" \ | |
-X POST http://rancher-server/v1/services/1s10?action=finishupgrade |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment