Skip to content

Instantly share code, notes, and snippets.

@drewsonne
Last active September 20, 2017 09:41
Show Gist options
  • Save drewsonne/1325943c5d8f194a261b48887bac279a to your computer and use it in GitHub Desktop.
Save drewsonne/1325943c5d8f194a261b48887bac279a to your computer and use it in GitHub Desktop.
Re-create issues with update auto_update
#!/usr/bin/env bash
docker run -d -p8153:8153 -p8154:8154 gocd/gocd-server:v17.10.0
ENDPOINT="http://127.0.0.1:8153/go/api/admin/config.xml"
function get_status {
curl -H 'Accept: application/vnd.go.cd.v3+json' \
--write-out %{http_code} \
--silent \
--output /dev/null \
${ENDPOINT}
}
counter=0
wait_length=5
elapsed=0
while [ $counter -lt 30 ]; do
code=$(get_status)
if [ "200" == "$code" ]; then
echo "Got status ${code}. Exiting."
exit 0
fi
echo "Got status ${code}. Elapsed: '${elapsed}' seconds."
sleep "${wait_length}"
elapsed=$((elapsed+wait_length))
done
exit 1
#! /usr/bin/env bash
GOCD_HOST="${GOCD_HOST:-http://localhost:8153}"
echo "CREATING PIPELINE1...\n"
curl "${GOCD_HOST}/go/api/admin/pipelines" \
-H 'Accept: application/vnd.go.cd.v4+json' \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"group": "test",
"pipeline": {
"name": "pipeline1",
"stages": [{
"name": "test-stage",
"jobs": [{
"name": "test-job"
}]
}],
"materials": [{
"type": "git",
"attributes": {
"auto_update": true,
"url": "https://github.com/gocd/gocd"
}
}]
}
}'
echo "\n\nCREATING PIPELINE2...\n"
curl "${GOCD_HOST}/go/api/admin/pipelines" \
-H 'Accept: application/vnd.go.cd.v4+json' \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"group": "test",
"pipeline": {
"name": "pipeline2",
"stages": [{
"name": "test-stage",
"jobs": [{
"name": "test-job"
}]
}],
"materials": [{
"type": "git",
"attributes": {
"name": "gocd-source",
"auto_update": true,
"url": "https://github.com/gocd/gocd"
}
}]
}
}'
echo -e "\n\nGETTING PIPELINE2 VERSION..."
version=$(curl --silent "${GOCD_HOST}/go/api/admin/pipelines/pipeline2" \
-H 'Accept: application/vnd.go.cd.v4+json' \
-i | grep ETag| tr -d '\r' | cut -d ' ' -f2)
echo "Got Version: ${version}"
curl "${GOCD_HOST}/go/api/admin/pipelines/pipeline2" \
-H 'Accept: application/vnd.go.cd.v4+json' \
-H 'Content-Type: application/json' \
-H "If-Match: ${version}" \
-X PUT \
-i \
-v \
-d '{
"name": "pipeline2",
"stages": [{
"name": "test-stage",
"jobs": [{
"name": "test-job2"
}]
}],
"materials": [{
"type": "git",
"attributes": {
"name": "gocd-source",
"auto_update": false,
"url": "https://github.com/gocd/gocd"
}
}]
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment