Jenkins Git fetch 引用旧提交

Raj*_* Gr 5 git jenkins jenkins-plugins jenkins-pipeline

我正在为 Angular 6 应用程序创建 Jenkins CI 流程。我创建了一个多配置项目。并在配置中选择以下值:

源代码管理:
Git:Repo_URL
要构建的分支:*/master
存储库浏览器:自动

构建触发器:
Gerrit 事件:已选中

Gerrit 触发器:
选择服务器:gerrit.*.com
触发器:已创建补丁集
添加的命令包含正则表达式:[Rr][Ee][Vv][Ee][Rr][Ii][Ff][Yy]

动态触发器配置:
Gerrit 项目:
类型:Plair 模式:projName
分支:
类型:Plair 模式:master

构建环境:
将 Node 和 npm bin/ 文件夹提供到 PATH:NodeJS 路径
npmrc 文件:系统默认值

构建:
命令:
echo $PATH
node --version
npm --version
npm install -g @angular/cli
ng build

当我提交代码或重新验证时,构建会被触发,但它会获取先前的提交,而不是触发构建的最新提交。

以下是构建日志:

10:55:56 Cloning the remote Git repository      
10:55:56 Cloning repository ssh://rmp-bot@***       
10:55:56  > git init /var/lib/jenkins/workspace/application_name/Patchset-Sonar-CI-master # timeout=10          
10:55:56 Fetching upstream changes from ssh://rmp-bot@***             
10:55:56  > git --version # timeout=10        
10:55:56 using GIT_SSH to set credentials Gerrit ssh user              
10:55:56  > git fetch --tags --progress ssh://rmp-bot@***   +refs/heads/*:refs/remotes/origin/*                           
10:55:57  > git config remote.origin.url ssh://rmp-bot@*** # timeout=10
10:55:57  > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10            
10:55:57  > git config remote.origin.url ssh://rmp-bot@*** # timeout=10           
10:55:57 Fetching upstream changes from ssh://rmp-bot@***        
10:55:57 using GIT_SSH to set credentials Gerrit ssh user               
10:55:57  > git fetch --tags --progress ssh://rmp-bot@***  +refs/heads/*:refs/remotes/origin/*                   
10:55:57  > git rev-parse refs/remotes/origin/master^{commit} # timeout=10          
10:55:57  > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10                
10:55:57 Checking out Revision fc96e9e083c368ff963114914fede303d885ae6a (refs/remotes/origin/master)           
10:55:57  > git config core.sparsecheckout # timeout=10                 
10:55:57  > git checkout -f fc96e9e083c368ff963114914fede303d885ae6a 
Run Code Online (Sandbox Code Playgroud)

不同项目类型的设置适用于其他应用程序 Jenkins 设置。请告诉我上面的配置出了什么问题。

我还尝试在 SCM -> Git -> Repositores 中添加 Refspec: refs/changes/ :refs/changes/ & Name: origin 。但仍然面临同样的问题。

Raj*_* Gr 0

通过在 SCM -> Git -> Repositores 中为 Refspec: refs/changes/ :refs/changes/提供正确的值即可解决此问题。