#!/bin/bash

if [ $# -ne 1 ]; then
	echo "usage: $(basename $0) \"the cookie\""
	echo See "https://blog.dahanne.net/2016/05/17/how-to-update-a-jenkins-job-posting-config-xml/#Security_based_on_cookies_no_user_password" for how to get the cookie.
	exit 2
fi

cd "$(dirname $0)"
for platform in mac windows; do
	for type in commit nightly release; do
		echo "Updating twig-sdk-$platform-build-$type"
		curl -X POST "https://jenkins.internal.justin.tv/job/$job/config.xml" -H "Cookie: $1" --data-binary @$job.xml || exit 1
	done
done
