# githubPostCommitStatus

This step sets a commit status in Github.

## Parameters

| Name          | Description                                                                   | Type     | Default          | Required |
| ------------- | ----------------------------------------------------------------------------- | -------- | ---------------- | -------- |
| repo          | The Github repository name                                                    | `String` | n/a              | yes      |
| state         | The state of the status. Can be one of: error, failure, pending, success      | `String` | n/a              | yes      |
| description   | A short description of the status.                                            | `String` | n/a              | yes      |
| context       | A string label to differentiate this status from the status of other systems. | `String` | n/a              | yes      |
| targetUrl     | The target URL to associate with this status.                                 | `String` | `env.JOB_URL`    | yes      |
| owner         | The Github repository owner                                                   | `String` | 'theorchard'     | no       |
| pullRequestId | Id of the pull request                                                        | `String` | `env.GIT_COMMIT` | no       |

## Usage

Note that the git commit hash is automatically picked up using the the `env.GIT_COMMIT` variable. If you don't provide targetUrl, url of the job which invokes the method will be used.

### Post a comment on stage success

```groovy
stage('Some task') {
    steps {
        performSomeTask()
    }
    post {
        success {
            githubPostCommitStatus(
                repo: 'frontend-test',
                description: '🚀 Task is done!'
                state: 'success'
                context: 'my-check-context'
            )
        }
        failure {
            githubPostCommitStatus(
                repo: 'frontend-test',
                description: 'Task is not done.'
                state: 'failure'
                context: 'my-check-context'
            )
        }
    }
}
```
