Skip to content

Instantly share code, notes, and snippets.

@ryanlfoster
Forked from gabro/notify_build_result.sh
Created October 22, 2015 04:47
Show Gist options
  • Save ryanlfoster/dc1be6a6ee5e846ea31c to your computer and use it in GitHub Desktop.
Save ryanlfoster/dc1be6a6ee5e846ea31c to your computer and use it in GitHub Desktop.

Revisions

  1. @gabro gabro revised this gist May 28, 2015. 2 changed files with 11 additions and 0 deletions.
    File renamed without changes.
    11 changes: 11 additions & 0 deletions notify_build_started.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/bin/bash
    GITHUB_API=https://api.github.com
    AUTH_TOKEN= # GITHUB API TOKEN HERE

    REPO= # REPO NAME HERE
    URL=${bamboo.buildResultsUrl}
    SHA=${bamboo.repository.revision.number}
    PENDING_DESCRIPTION="The Bamboo CI build is in progress"
    GITHUB_STATUS_ENDPOINT=$GITHUB_API/repos/$REPO/statuses/$SHA

    curl -k -H "Authorization: token $AUTH_TOKEN" --request POST --data "{\"state\": \"pending\", \"description\": \"$PENDING_DESCRIPTION\", \"target_url\": \"$URL\"}" $GITHUB_STATUS_ENDPOINT > /dev/null
  2. @gabro gabro revised this gist May 28, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions notify build result
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    #!/bin/bash
    GITHUB_API=https://api.github.com
    AUTH_TOKEN=$APITOKEN # GITHUB API TOKEN HERE
    AUTH_TOKEN= # GITHUB API TOKEN HERE

    REPO=$REPO_NAME # REPO NAME HERE
    REPO= # REPO NAME HERE
    URL=${bamboo.buildResultsUrl}
    SHA=${bamboo.repository.revision.number}
    SUCCESS_DESCRIPTION="The Bamboo CI build passed"
  3. @gabro gabro renamed this gist May 28, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @gabro gabro created this gist May 28, 2015.
    20 changes: 20 additions & 0 deletions notify failed build
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/bin/bash
    GITHUB_API=https://api.github.com
    AUTH_TOKEN=$APITOKEN # GITHUB API TOKEN HERE

    REPO=$REPO_NAME # REPO NAME HERE
    URL=${bamboo.buildResultsUrl}
    SHA=${bamboo.repository.revision.number}
    SUCCESS_DESCRIPTION="The Bamboo CI build passed"
    FAILURE_DESCRIPTION="Build #${bamboo.buildNumber} failed"

    # lol (mocha.json generated by mocha-bamboo-reporter)
    FAILED_TESTS=`grep -o '"failures": \d\+' mocha.json | cut -f2 -d" "`

    GITHUB_STATUS_ENDPOINT=$GITHUB_API/repos/$REPO/statuses/$SHA

    if [ $FAILED_TESTS == 0 ]; then
    curl -k -H "Authorization: token $AUTH_TOKEN" --request POST --data "{\"state\": \"success\", \"description\": \"$SUCCESS_DESCRIPTION\", \"target_url\": \"$URL\"}" $GITHUB_STATUS_ENDPOINT > /dev/null
    else
    curl -k -H "Authorization: token $AUTH_TOKEN" --request POST --data "{\"state\": \"failure\", \"description\": \"$FAILURE_DESCRIPTION\", \"target_url\": \"$URL\"}" $GITHUB_STATUS_ENDPOINT > /dev/null
    fi