How To access commit message as a built-in variable?

image
How To access the commit message as a built-in variable?

Usecase:

1. Is there a built-in variable for the commit message in the Harness? 

As part of this article, we will answer how to achieve this usecase:

  • There is no built-in variable for a commit message. However, as a workaround, you can use the git log to get it in a run step.

  • You can use GitHub APIs
    First way: This will give you the commit message Commits - GitHub Docs
    Second way: You can use the below API Commits - GitHub Docs. Use JSON path or any parser to filter the commit message based on commit-Id

  • If the commit message is the same as the PR title, then you can use this. echo <+codebase.prTitle>

This is how you can achieve your usecase of accessing a commit message as a variable in Harness. To find more on Harness built-in variables, please review our docs here: Built-in CI codebase variables reference | Harness Developer Hub Which talks about all Built-in CI codebase variables reference in Harness.

2 Likes