I'm creating Jenkins CI flow for an angular 6 application. I created a Multi-Configuration project. And selected below values in the configuration:
Source Code Management:
Git: Repo_URL
Branches to build: */master
Repository browser: Auto
Build Triggers:
Gerrit event: checked
Gerrit Trigger:
Choose a server: gerrit.*.com
Trigger on: Patchset created
Command Added Contains Reg Exp: [Rr][Ee][Vv][Ee][Rr][Ii][Ff][Yy]
Dynamic Trigger Configuration:
Gerrit Project:
Type: Plair Pattern: projName
Branches:
Type: Plair Pattern: master
Build Environment:
Provide Node & npm bin/ folder to PATH: NodeJS path
npmrc file: system default
Build:
Command:
echo $PATH
node --version
npm --version
npm install -g @angular/cli
ng build
When I commit the code or when I do reverify, the build is getting triggered but it is fetching previous commit instead of the latest commit which is triggering the build.
Below is the build log:
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
The setup with different project type is working for other Applications Jenkins setup. Please let me know what went wrong in the above configuration.
I also tried adding Refspec: refs/changes/:refs/changes/ & Name: origin in SCM -> Git -> Repositores. But still facing the same issue.
The issue is resolved by providing the proper value for Refspec: refs/changes/:refs/changes/ in SCM -> Git -> Repositores.