我正在尝试使用 Jenkins 管道脚本标记 git repo。我对 Jenkins 管道脚本很陌生。
有没有像下面这样的命令来标记分支,用于 checkout 分支
git branch: 'master',
credentialsId: '12345-1234-4696-af25-123455',
url: 'ssh://git@bitbucket.org:company/repo.git'
最佳答案
git
命令是 shorthand for the checkout
步。它只能从 repo 克隆。
如果要执行通用 git 命令,则需要设置连接凭据。对于 SSH,最简单的方法是使用 SSH Agent Plugin .对于某些操作,您还需要配置本地 git 用户属性。
例子:
# configure git
sh '''
git config --global user.email 'my@company.org'
git config --global user.name 'This Is Me'
git tag this-very-version
'''
# enable remote connection
sshagent (credentials: ['your-credentials-to-bitbucket']) {
sh 'git push origin this-very-version'
}
关于git - 使用 jenkins 管道脚本标记 git repo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52488558/