Skip to content

githubSetCommitStatus

Set a status of a certain commit.

Prerequisites

You need to create a personal access token within GitHub and add this to the Jenkins credentials store.

Please see GitHub documentation for details about creating the personal access token.

Parameters

Overview

Name Mandatory Additional information
commitId yes
context yes
owner yes
repository yes
script yes Jenkins only reference to Jenkins main pipeline script
status yes
token yes Secret pass via ENV or Jenkins credentials (githubTokenCredentialsId)
apiUrl no
description no
targetUrl no
verbose no activates debug output

Details

apiUrl

Set the GitHub API URL.

back to overview

Scope Details
Aliases githubApiUrl
Type string
Mandatory no
Default https://api.github.com
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

commitId

The commitId for which the status should be set.

back to overview

Scope Details
Aliases -
Type string
Mandatory yes
Default $PIPER_commitId (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: git/commitId

context

Label for the status which will for example show up in a pull request.

back to overview

Scope Details
Aliases -
Type string
Mandatory yes
Default $PIPER_context (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

description

Short description of the status.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_description (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

owner

Name of the GitHub organization.

back to overview

Scope Details
Aliases githubOrg
Type string
Mandatory yes
Default $PIPER_owner (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: github/owner

repository

Name of the GitHub repository.

back to overview

Scope Details
Aliases githubRepo
Type string
Mandatory yes
Default $PIPER_repository (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: github/repository

script

Jenkins-specific: Used for proper environment setup.

The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this parameter, as in script: this. This allows the function to access the commonPipelineEnvironment for retrieving, e.g. configuration parameters.

back to overview

Scope Details
Aliases -
Type Jenkins Script
Mandatory yes
Default
Secret no
Configuration scope
  • ☐ parameter
  • ☐ general
  • ☐ steps
  • ☐ stages
Resource references none

status

Status which should be set on the commitId.

back to overview

Scope Details
Aliases -
Type string
Mandatory yes
Default $PIPER_status (if set)
Possible values - failure
- pending
- success
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

targetUrl

Target URL to associate the status with.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_targetUrl (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

token

GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line.

back to overview

Scope Details
Aliases githubToken
Type string
Mandatory yes
Default $PIPER_token (if set)
Secret yes
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references Jenkins credential id:
  id: githubTokenCredentialsId
  reference to: ``

verbose

verbose output

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

githubTokenCredentialsId

Jenkins-specific: Used for proper environment setup. See using credentials for details.

Jenkins 'Secret text' credentials ID containing token to authenticate to GitHub.

back to overview

Scope Details
Aliases -
Type string
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages

Description

This step allows you to set a status for a certain commit. Details can be found here: https://developer.github.com/v3/repos/statuses/.

Typically, following information is set:

  • state (pending, failure, success)
  • context
  • target URL (link to details)

It can for example be used to create additional check indicators for a pull request which can be evaluated and also be enforced by GitHub configuration.

Usage

We recommend to define values of step parameters via config.yml file. In this case, calling the step is reduced to one simple line.
Calling the step can be done either via the Jenkins library step or on the command line.

Jenkins Pipeline

library('piper-lib-os')

githubSetCommitStatus script: this

Command Line

piper githubSetCommitStatus