# setBuildStatusSuccess

Adds the ability to update GHE commits/PRs with build statuses for individual steps as passed.

**PREREQUISITES**

* [Create credentials in Jenkins that](https://www.jenkins.io/doc/book/using/using-credentials/#adding-new-global-credentials) that are of kind `Username with password`.
  * Set the username to your GHE user
  * Set the password to your PAT [(PAT creation instructions here)](https://help.github.com/en/enterprise/2.17/user/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
  * The ID should be something easily distinguishable for your org, this ID is what gets fed into `credentialsId` below

**USAGE**

Example:

```groovy
@Library('flexo-libs') _

pipeline {
    agent any
    stages {
        // All you need is the credentialsId to be passed in.
        // Sane defaults will probably be fine for most use cases
        // At most, you may want to look at the example_with_more_options stage below and add a description
        stage('minimal_example') {
            steps {
                setBuildStatusPending(
                    credentialsId: 'my-service_pat'
                )
                echo 'Hello build!'
            }
            post {
                success {
                    setBuildStatusSuccess(
                        credentialsId: 'my-service_pat',
                        description: 'This description is optional"
                    )
                }
                failure {
                    setBuildStatusFailure(
                        credentialsId: 'my-service_pat'
                    )
                }
            }
        }

        stage('example_with_more_options') {
            steps {
                setBuildStatusPending(
                    description: 'Add a description for when you hover over the status in GHE',
                    context: 'By default, the context shown in GHE will be the STAGE_NAME - example_with_more_options - so we can override that here'
                    credentialsId: 'my-service_pat',
                    debug: true // For some extra debug output of what the plugin is doing (some output will be in /var/log/jenkins.log)
                )
                echo 'Hello build!'
            }
            post {
                success {
                    setBuildStatusSuccess(
                        description: 'example success',
                        context: 'Successful Example Step',
                        credentialsId: 'my-service_pat'
                    )
                }
                failure {
                    setBuildStatusFailure(
                        description: 'example failure',
                        credentialsId: 'my-service_pat'
                    )
                }
            }
        }
    }
}
```
