README.md

March 24, 2026 ยท View on GitHub

Git Pull Request event trigger with set PR/MR commit status

This sample-git-pr-status sub-directory contains several EventListener definitions that you can include in your CD tekton pipeline configuration to run an example demonstrating the usage of the git-set-commit-status in the context of a CD Tekton pipeline triggered by a Git Pull Request event (PullRequest push/update).

This sample illustrates the PullRequest support provided by the git-clone-repo that results in a Git repository content that would be identical to the one obtained after a merge action on the given PullRequest (or Merge Request for a Gitlab or GRIT server).

It is also showcase the git-set-commit-statusto create/update Pull Request status check (i.e. set commit status on the last commit of the Pull Request). The status being sucess or failing according to the commit message (it the commit message contains fail then the status is failed otherwise it is success)

  1. Create or update a Toolchain to include:

    • the github.com repository that you want to clone
    • (optional) the GRIT repository that you want to clone
    • (optional) the BitBucket repository that you want to clone
    • the repository containing this Tekton task
    • a Tekton pipeline definition

    Toolchain overview

  2. Add the definitions of this task and the sample (git and git/sample-git-pr-status paths)

    Tekton pipeline definitions

  3. Add the environment properties:

    • apikey: the API key used for the ibmcloud login/access

    Tekton pipeline environment properties

  4. Create Git Triggers for the different Git repositories that you have integrated to your Toolchain (corresponding to the repositories integrated to your Toolchain).

    Github:

    • eventlistener-git-pr-status-github-pr for Github PullRequest opened/updated event

      Tekton pipeline sample-git-trigger Github PullRequest

    GRIT/Gitlab:

    • eventlistener-git-pr-status-grit-mr for GRIT/Gitlab MergeRequest opened/updated event

    BitBucket:

    • eventlistener-git-pr-status-bitbucket-pr for BitBucket PullRequest opened/updated event
  5. Trigger on PullRequest: in one of your repository that has the above triggers defined, define a new Git branch, push some code changes and create a new PullRequest to the default master branch.

    Tekton pipeline github new-branch commit

    Tekton pipeline github pullrequest new-branch

    Observe: a new pipeline run is automatically started, triggered by this PullRequest.

    Tekton pipeline sample-git-trigger run on pr event

    Notes:

    • The clone-task execution will produce the same repository content as the "Merge Pull Request" action/button would.
    • The set-git-commit-status task execution will use the inspect-git-commit-message pipelinerun task execution status to update the PullRequest commit status

    Tekton pipeline github pull request run view

    The Pull Request status check is updated as the last commit has a commit status

    github pull request status check

    Note: in case of a commit message containing fail the task will result in a failure and the finally clause in the pipeline definition will still execute the set-git-commit-status task with the appropriate state

    Tekton pipeline github pull request run view

    The Pull Request status check is updated to failure corresponding to the last commit status

    github pull request status check

Detailed Description

This pipeline and relevant trigger(s) can be configured using the properties described below.

See https://cloud.ibm.com/docs/ContinuousDelivery?topic=ContinuousDelivery-tekton-pipelines&interface=ui#configure_tekton_pipeline for more information.

EventListeners:

eventlistener-git-pr-status-github-pr

EventListener: eventlistener-git-pr-status-github-pr - github pull-request listener to set status on pull-request commit

PropertiesDescriptionDefaultRequiredType
apikey (secured property)the api key used to login to ibmcloud-Yessecret
branchthe branch for the git repo$(event.pull_request.base.ref)Nostring
context-commit message checkNostring
description-verify the commit messageNostring
git-access-tokenthe token to access the git repository for the clone operations``Nostring
git-credentials-json-file-output/secrets/thecredentials.jsonNostring
pipeline-debugPipeline debug mode. Value can be 0 or 1.0Nostring
pr-branchThe source branch for the PullRequest$(event.pull_request.head.ref)Nostring
pr-repositoryThe source git repo for the PullRequest$(event.pull_request.head.repo.clone_url)Nostring
pr-revisionthe commit id/sha for the PullRequest$(event.pull_request.head.sha)Nostring
properties-file-output/thebuild.propertiesNostring
repositorythe git repo$(event.pull_request.base.repo.clone_url)Nostring
triggerNamename of the triggergithub-pullrequestNostring

eventlistener-git-pr-status-grit-mr

EventListener: eventlistener-git-pr-status-grit-mr - grit/gitlab merge-request listener to set status on merge-request commit

PropertiesDescriptionDefaultRequiredType
apikey (secured property)the api key used to login to ibmcloud-Yessecret
branchthe branch for the git repo$(event.object_attributes.target_branch)Nostring
context-commit message checkNostring
description-verify the commit messageNostring
git-access-tokenthe token to access the git repository for the clone operations``Nostring
git-credentials-json-file-output/secrets/thecredentials.jsonNostring
pipeline-debugPipeline debug mode. Value can be 0 or 1.0Nostring
pr-branchThe source branch for the PullRequest$(event.object_attributes.source_branch)Nostring
pr-repositoryThe source git repo for the PullRequest$(event.object_attributes.source.git_http_url)Nostring
pr-revisionthe commit id/sha for the PullRequest$(event.object_attributes.last_commit.id)Nostring
properties-file-output/thebuild.propertiesNostring
repositorythe git repo$(event.object_attributes.target.git_http_url)Nostring
triggerNamename of the triggergrit-mergerequestNostring

eventlistener-git-pr-status-bitbucket-pr

EventListener: eventlistener-git-pr-status-bitbucket-pr - bitbucket pull-request listener to set status on pull-request commit

PropertiesDescriptionDefaultRequiredType
apikey (secured property)the api key used to login to ibmcloud-Yessecret
branchthe branch for the git repo$(event.pullrequest.destination.branch.name)Nostring
context-commit message checkNostring
description-verify the commit messageNostring
git-access-tokenthe token to access the git repository for the clone operations``Nostring
git-credentials-json-file-output/secrets/thecredentials.jsonNostring
pipeline-debugPipeline debug mode. Value can be 0 or 1.0Nostring
pr-branchThe source branch for the PullRequest$(event.pullrequest.source.branch.name)Nostring
pr-repositoryThe source git repo for the PullRequest$(event.pullrequest.source.repository.links.html.href)Nostring
pr-revisionthe commit id/sha for the PullRequest$(event.pullrequest.source.commit.hash)Nostring
properties-file-output/thebuild.propertiesNostring
repositorythe git repo$(event.pullrequest.destination.repository.links.html.href)Nostring
triggerNamename of the triggerbitbucket-pullrequestNostring