Send Source Control Build Status from Pipelines

JFrog Pipelines Documentation

ft:sourceType
Paligo

Where many CI automation servers require a plugin or custom integration to send build status to a source control repository, Pipelines provides a built-in utility function that can be used in any step.

To send build status from a pipeline step to a commit in a source repository, you must:

  1. Declare the GitRepo in the step's inputresources .

  2. Use the update_commit_status utility function in any of the step's execution blocks:onStart, onExecute, onFailure, or onSuccess.

The format of the update_commit_status function is:

update_commit_status <gitRepo resource name> --status <status> --message <message> --context <context>

You must specify the GitRepo resource in the update_commit_status function. The remaining parameters are all optional. By default, the function will infer the status from the execution block where it is invoked. Default message and context strings are constructed from the step and pipeline name.

For example, this step will update the commit's build status for each execution phase using the defaults:

pipelines:
  - name: git_status_defaults
    steps:
      - name: status_update_defaults
        type: Bash
        configuration:
          inputResources:
            - name: myGitRepo
        execution:
          onStart:
            - update_commit_status myGitRepo                # Status: "processing"
          onExecute:
            - update_commit_status myGitRepo                # Status: "processing"
            - echo "Hello World!"
          onFailure:
            - update_commit_status myGitRepo                # Status: "failure"
          onSuccess:
            - update_commit_status myGitRepo                # Status: "success"

When the above example pipeline is run:

  • The receiving source repository will create a status log entry for the step.

  • Each call to update_commit_status will overwrite the status and message values of that log entry.

The resulting build status log for the commit can be viewed in the source repository's UI (on GitHub):

image2020-2-3_11-42-14.png