use*_*412 4 git jenkins jenkins-plugins jenkins-pipeline
我正在尝试使用 Jenkins 管道脚本标记 git 存储库。我对詹金斯管道脚本非常陌生。
是否有像下面这样的命令来标记分支,用于签出分支
git branch: 'master',
credentialsId: '12345-1234-4696-af25-123455',
url: 'ssh://git@bitbucket.org:company/repo.git'
Run Code Online (Sandbox Code Playgroud)
该git命令是步骤的简写checkout。它只能从存储库克隆。
如果您想执行通用 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'
}
Run Code Online (Sandbox Code Playgroud)