'Build Manual GitlabCI pipeline job using specific Commit ID

I need to build a Gitlab CI pipeline manually but not using latest of my master branch, but using a specific commitID. I have tried running pipeline manually by using variable as below and passing its value but of no use.

Input variable key: CI_COMMIT_SHA


Solution 1:[1]

At the time of this writing, GitLab only supports branch/tag pipelines, merge request pipelines and scheduled pipelines. You can't run a GitLab pipeline for a specific commit, since the same commit may belong to multiple branches.

To do what you want, you need to create a branch from the commit you want to run the pipeline for. Then you can run the manual pipeline on that branch.

See this answer for step-by-step instructions on how to create a branch from a commit directly in the GitLab UI.

Solution 2:[2]

Use the existing (created by Gitlab CI) workspace to run the .gitlab-ci.yml and from there checkout the code again in a different directory using commitID, and perform all the operations there.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Sunil