Skip to content

Instantly share code, notes, and snippets.

@colelawrence
Created July 22, 2016 16:20
Show Gist options
  • Select an option

  • Save colelawrence/b6d41d4fb93ecd17dd63341f00e6773b to your computer and use it in GitHub Desktop.

Select an option

Save colelawrence/b6d41d4fb93ecd17dd63341f00e6773b to your computer and use it in GitHub Desktop.
Create github API call with curl
# DRONE_COMMIT commit sha
# DRONE_BUILD_LINK
# DRONE_REPO_OWNER repository owner
# DRONE_REPO_NAME repository name
# From github:
# POST /repos/:owner/:repo/statuses/:sha
export GITHUB_API=https://api.github.com
export BODY=<< EOF
{
"state": "failure", # pending, error, or failure.
"target_url": "https://example.com/build/status",
"description": "The build failed!",
"context": "test/test"
}
EOF
curl -i \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X POST -d "$BODY" \
"$GITHUB_API/repos/$DRONE_REPO_OWNER/$DRONE_REPO_NAME/statuses/$DRONE_COMMIT_SHA"
# {
# "state": "success", # pending, error, or failure.
# "target_url": "https://example.com/build/status",
# "description": "The build succeeded!",
# "context": "continuous-integration/jenkins"
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment