Skip to content

Instantly share code, notes, and snippets.

@adikari
Created May 26, 2020 04:08
Show Gist options
  • Save adikari/d85b2fba3a971a4339a661dc355c174b to your computer and use it in GitHub Desktop.
Save adikari/d85b2fba3a971a4339a661dc355c174b to your computer and use it in GitHub Desktop.
#!/bin/bash
function create_merge_pipeline() {
local repo=$1
local pipeline=$2
local command=$3
echo "Creating merge pipeline: $pipeline ..."
curl -X POST "https://api.buildkite.com/v2/organizations/a-cloud-guru/pipelines" \
-H "Authorization: Bearer $BUILDKITE_TOKEN" \
-d '{
"name": "'"$pipeline"'",
"repository": "'"$repo"'",
"steps": [
{
"type": "script",
"name": ":buildkite:",
"command": "'"$command"'"
}
],
"default_branch": "master",
"branch_configuration": "master",
"provider_settings": {
"trigger_mode": "none"
}
}'
}
function create_deploy_pipeline() {
local repo=$1
local pipeline=$2
local command=$3
echo "Creating deploy pipeline: $pipeline ..."
curl -X POST "https://api.buildkite.com/v2/organizations/a-cloud-guru/pipelines" \
-H "Authorization: Bearer $BUILDKITE_TOKEN" \
-d '{
"name": "'"$pipeline"'",
"repository": "'"$repo"'",
"steps": [
{
"type": "script",
"name": ":buildkite:",
"command": "'"$command"'"
}
],
"default_branch": "master",
"provider_settings": {
"trigger_mode": "none"
}
}'
}
function create_pr_pipeline() {
local repo=$1
local pipeline=$2
local command=$3
echo "Creating pull-request pipeline: $pipeline ..."
curl -X POST "https://api.buildkite.com/v2/organizations/a-cloud-guru/pipelines" \
-H "Authorization: Bearer $BUILDKITE_TOKEN" \
-d '{
"name": "'"$pipeline"'",
"repository": "'"$repo"'",
"steps": [
{
"type": "script",
"name": ":buildkite:",
"command": "'"$command"'"
}
],
"default_branch": "",
"cancel_running_branch_builds": true,
"branch_configuration": "!master",
"provider_settings": {
"trigger_mode": "none"
}
}'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment