Git储存库的Jenkins管道跟踪参考

问题描述

我们正在尝试使用自动代码审查工具(Pronto)作为Jenkins管道运行的一部分。

该工具界面的一部分是它需要“开始提交”以供引用,换句话说:

       d -- e -- f -- g 
      / 
a -- b -- c

该工具假设HEAD位于 g ,并且将使用参数--commit b(或解析为 b )。

在我们的Jenkins设置中,该设置使用checkout scm步骤并通过稍微包裹的groovy扩展名(请参见下文),这会检查出最后一百个提交中的浅层提交,并带有非常具体的refspec,我认为这是问题所在。refspec不包含通配符,因此当我们尝试使用-c origin/master运行我们的工具时,refspec无法解决

scmCheckout函数所采取的步骤的完整列表在此处(略述):

using credential 3db58f3d-60a0-••••-••••-••••••••
cloning the remote Git repository
cloning with configured refspecs honoured and without tags
cloning repository https://github.com/••••••••.git
 > git init /data/jenkins/workspace/api_ci_chore-somefeature@5_CXQ52MT8 # timeout=10
Fetching upstream changes from https://github.com/••••••••.git
 > git --version # timeout=10
 > git --version # 'git version 2.7.4'
using GIT_ASKPASS to set credentials Old ID: c91dde6a-f6a2-41c0-••••-••••-••••••••
 > git fetch --no-tags --progress https://github.com/••••••••.git +refs/heads/chore-somefeature:refs/remotes/origin/chore-somefeature # timeout=10
Fetching without tags
 > git config remote.origin.url https://github.com/••••••••.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/chore-somefeature:refs/remotes/origin/chore-somefeature # timeout=10
 > git config remote.origin.url https://github.com/••••••••.git # timeout=10
Fetching upstream changes from https://github.com/••••••••.git
using GIT_ASKPASS to set credentials Old ID: c91dde6a-f6a2-41c0-••••-••••-••••••••
 > git fetch --no-tags --progress https://github.com/••••••••.git +refs/heads/chore-somefeature:refs/remotes/origin/chore-somefeature # timeout=10
Checking out Revision •••••••• (chore-somefeature)
Commit message: "try and fetch more of the repo before we stash/etc"
 > git config core.sparsecheckout # timeout=10
 > git checkout -f •••••••• # timeout=10
 > git rev-list --no-walk •••••••• # timeout=10

我相信问题来自git fetch --no-tags --progress https://github.com/••••••••.git +refs/heads/chore-somefeature:refs/remotes/origin/chore-somefeature中的高度特定的refspec。

这是我们的scmCheckout.groovy

import org.apache.commons.lang.RandomStringUtils

def call(def body) {
  def randomString = RandomStringUtils.random(8,(('A'..'Z')+('0'..'9')).join().tochararray())
  ws(WORKSPACE + "_" + randomString) {
    scmVars = checkout scm
    scmVars.each { k,v ->
      env[k] = v
    }
    body.call()
  }
}

尝试稍后在管道错误中执行带有git凭证错误的操作。

我想知道以下两件事之一:

  • Jenkins是否在分支的第一次提交中提供env变量(我不这样认为),所以我可以避免使用refspec查找来解决origin/master中的提交?

  • 如何才能尽早运行git remote set-branches origin '*' && git fetch --depth=100之类的东西,并且在适当的上下文中可以绕过checkout scm使用的有限refspec或将其添加? >

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)