Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-25792

Bamboo is unable to send Failed build status to GIthub

      Issue Summary

      When we try to use a webhook as a notification to try to send failed build status from Bamboo to GITHUB for particular commit id, its failing with the status code 422

      {"message":"Validation Failed","errors":[{"resource":"Status","code":"custom","field":"state","message":"state is not included in the list"}],"documentation_url":"https://docs.github.com/rest/commits/statuses#create-a-commit-status"}
      
      

      This is reproducible on Data Center: (yes) / (no) yes

      Steps to Reproduce

      1. Intergrate Bamboo with GITHUB
      2. Configure Bamboo to trigger build after a commit in GITHUB - https://confluence.atlassian.com/bamkb/how-to-trigger-bamboo-builds-with-github-webhook-1097179080.html

      https://confluence.atlassian.com/bamkb/how-to-send-bamboo-build-status-to-github-via-webhook-1369639847.html

      3. Try to send the Bamboo build results to GITHUB

      For that we need to set up a webhook to transfer Bamboo build status to GITHUB commit via notifications in build plan.

      4. Use the below payload and header

      Payload :-

      {"state":"${'${bamboo.buildState}'?lower_case}","target_url":"${bamboo.buildResultsUrl}","description":"${bamboo.buildState}","context":"continuous-integration/bamboo"}
      

      Header :-

      Accept: application/vnd.github+json
      Authorization: Bearer <use your github token>
      
      

      Use the below notification url

      https://api.github.com/repos/ <GitHub username>/<repo name>/statuses/${bamboo.planRepository.revision}

      Expected Results

      The build status , target url , description and context arer passed to GITHUB for the commit ID

      Actual Results

      The webhook execution fails with status code 422

      {"message":"Validation Failed","errors":[{"resource":"Status","code":"custom","field":"state","message":"state is not included in the list"}],"documentation_url":"https://docs.github.com/rest/commits/statuses#create-a-commit-status"}
      

      However the problem is that GITHUB expects Bamboo to send the status of failed build as "failure" however Bamboo is sending the status as "FAILED" which GITHUB is not accepting

      state string Required
      The state of the status.
      
      Can be one of: error, failure, pending, success
      

      This is a follow up to https://jira.atlassian.com/browse/BAM-25700 where we fixed the success part. where GITHUB expects Bamboo to send the status in lower case i.e "success". Bamboo was sending this as uppercase "SUCCESS". Now the issue is with failed builds.

      Workaround

      No workaround as of now.

      Try to use this external third party plugin instead : https://github.com/HackAttack/bamboo-github-status

            [BAM-25792] Bamboo is unable to send Failed build status to GIthub

            Conny Postma made changes -
            Remote Link Original: This issue links to "Page (Atlassian Documentation)" [ 972255 ]

            Frederik added a comment -

            Thank you for the quick response 851f15845f55! We were indeed missing the "commit statuses" permission on our fine-grained access token. Now it’s working.

            Frederik added a comment - Thank you for the quick response 851f15845f55 ! We were indeed missing the "commit statuses" permission on our fine-grained access token. Now it’s working.
            Frederik made changes -
            Comment [ [~851f15845f55] is there some documentation on this feature you could point me to? [This page|https://confluence.atlassian.com/bamboo/github-289277001.html] just says that it should be "set up automatically", but I don’t see any build status in GitHub after a successful build. Then there is also [this doc entry|https://confluence.atlassian.com/bamkb/how-to-send-bamboo-build-status-to-github-via-webhook-1369639847.html], which I think is outdated? ]

            3d4153b3225e Please make sure your repository is of "GitHub repository"  type and that the token you used to configure it has all the scopes mentioned in https://confluence.atlassian.com/bamboo/github-289277001.html "To learn how to create personal access tokens...".

            In case it doesn't work, you may try to enable debug on `com.atlassian.bamboo.plugins.github.GithubBuildStatusUpdater`, we provide verbose logging on what is going on when sending a build status to GitHub. 

            Mateusz Szmal added a comment - 3d4153b3225e Please make sure your repository is of "GitHub repository"  type and that the token you used to configure it has all the scopes mentioned in https://confluence.atlassian.com/bamboo/github-289277001.html "To learn how to create personal access tokens...". In case it doesn't work, you may try to enable debug on `com.atlassian.bamboo.plugins.github.GithubBuildStatusUpdater`, we provide verbose logging on what is going on when sending a build status to GitHub. 
            Anik Sengupta made changes -
            Remote Link New: This issue links to "Page (Atlassian Documentation)" [ 972255 ]
            Bruno Benvenuti made changes -
            Resolution New: Fixed [ 1 ]
            Status Original: Waiting for Release [ 12075 ] New: Closed [ 6 ]
            SET Analytics Bot made changes -
            Support reference count Original: 1 New: 2
            Alexey Chystoprudov made changes -
            Fix Version/s New: 10.0.0-rc2 [ 108510 ]
            Shashank Kumar made changes -
            Remote Link New: This issue links to "Page (Confluence)" [ 912555 ]

            Hello,
            Since Bamboo 10.0, updating the GitHub build statuses will be supported out of the box! 

            Mateusz Szmal added a comment - Hello, Since Bamboo 10.0, updating the GitHub build statuses will be supported out of the box! 

              851f15845f55 Mateusz Szmal
              f84a05b06223 Anik Sengupta
              Affected customers:
              0 This affects my team
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: