git - 使用 jenkins 管道脚本标记 git repo

标签 git jenkins jenkins-plugins jenkins-pipeline

我正在尝试使用 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/

相关文章:

jenkins - 您如何处理声明式管道中的全局变量?

git - Jenkins 和 Git 配置问题

xcode - 如何从脚本设置 Jenkins 环境变量

Git 克隆无法创建文件

git - 在同一物理存储库上使用不同版本的 git 软件是否存在任何限制?

git - git log如何跨分支工作?

jenkins - DSL 种子作业 - 如何在 Jenkins 中使用 DSL 更新现有作业

java - 让jenkins和maven使用不同的java版本

git - 无法从 Git 存储库中删除 blob

Jenkins 管道: agent vs node?