prabhakar Reddy G
prabhakar Reddy G

Reputation: 1069

How can i checkout particular commit from the git scm from jenkins pipeline

I have following code to checkout master branch, if i want to checkout particluar commit from master branch, how can i achieve it.

parameters {
        stringParam("COMMIT_SHA", "", "[Required] Short SHA of the commit used to build the image")
    }
definition {
        cpsScm {
            scm {
                git {
                    remote {
                        url("https://github.mywork")
                        credentials("mytoken")
                    }
                    branches("master")
                }
            }
            scriptPath("azure/pipelines/build_service.jenkins")
        }
    }

I have tried

branches(master: ${COMMIT_SHA})

Upvotes: 0

Views: 901

Answers (1)

Noam Helmer
Noam Helmer

Reputation: 6824

These are the available options that can be used in the branch specifier when checking out a pipeline with Git:

enter image description here

So in your case you can just use: branches(COMMIT_SHA)

Upvotes: 1

Related Questions