Jenkins pipeline: checkout explicit git commit

只愿长相守 提交于 2019-12-03 01:37:53

Use a general scm step

checkout([$class: 'GitSCM', branches: [[name: commitHash ]],
     userRemoteConfigs: [[url: 'http://git-server/user/repository.git']]])

Yuri G's example didn't work for me when jenkins lacked a workspace due to initial checkout. The following works in this case. I don't understand why they are all that different.

    def commitId = "<insert sha here>"

    checkout ( [$class: 'GitSCM',
        branches: [[name: commitId ]],
        userRemoteConfigs: [[
            credentialsId: 'deploy key for your repo', 
            url: 'repo url']]])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!