0

I have a Jenkins multibranch pipeline hooked with GIT repo to do build from master and dev branches whenever a commit or pull request happens. I did the first time pull request from dev to master and build triggered correctly. Now I did a snapshot commit in dev branch but when the auto build is triggered through Jenkins it is taking the pom artifact version from master branch and not the snapshot which I updated in dev branch.

My pipeline looks like:

checkout([
$class: 'GitSCM', 
branches: [[name: '**']], 
doGenerateSubmoduleConfigurations: false, 
extensions: [[$class: 'CleanCheckout']],  
userRemoteConfigs: [[credentialsId: "xxx", 
url: 'ssh://somerepo/scm/anycomponent.git']]])

Log file from Jenkins:

    [Pipeline] checkout
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url ssh://somerepo/scm/anycomponent.git # timeout=10
Fetching upstream changes from ssh://somerepo/scm/anycomponent.git
> git --version # timeout=10
using GIT_ASKPASS to set credentials 
> git fetch --tags --progress ssh://somerepo/scm/anycomponent.git +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/development
Seen branch in repository origin/master
Seen 2 remote branches
> git show-ref --tags -d # timeout=10
Multiple candidate revisions
Checking out Revision 01t34567h9d94f3d1f99cb3e438n6789a5d17d2i (origin/master, refs/tags/SOME_TAG)
> git config core.sparsecheckout # timeout=10
> git checkout -f 01t34567h9d94f3d1f99cb3e438n6789a5d17d2i
Commit message: "Merge pull request #1 in REPO from development to master"
First time build. Skipping changelog.
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree

In the logs I can see Jenkins is taking the master pull request version and not the one I recently committed in Dev branch.

Any suggestion on what is wrong here?

  • How is auto build triggered ? Using webhooks ? Or polling SCM ? – ben5556 Oct 16 '18 at 18:36
  • Auto build is triggered though Webhooks. Thanks! – Amit Kapoor Oct 16 '18 at 19:11
  • From the logs it looks like it's returning only revisions with tags and picking up the latest revision with tag. Your second commit to dev branch doesn't have a tag does it ? Not sure why though. `git show-ref --tags -d # timeout=10` `Multiple candidate revisions` `Checking out Revision 01t34567h9d94f3d1f99cb3e438n6789a5d17d2i (origin/master, refs/tags/SOME_TAG)` – ben5556 Oct 16 '18 at 20:15
  • In your pipeline script `what does branches: [[name: '**']]` do ? This refers to whichever branch the webhook came from ? – ben5556 Oct 16 '18 at 20:18
  • Second commit to dev has a tag and it showed in the logs too (appears before the logs I pasted here). Couldn't understand why it was overridden by tag from master branch. – Amit Kapoor Oct 16 '18 at 21:24
  • You are right, '**' refers to whichever branch changes applied too (in my case both master and dev branches) – Amit Kapoor Oct 16 '18 at 21:26
  • But in your second commit changes were only applied to `development` branch so it should refer just development branch – ben5556 Oct 16 '18 at 21:27
  • yes but somehow it is keep on getting the commit tag of pull request from master branch. – Amit Kapoor Oct 17 '18 at 09:46
  • This _might_ be [a duplicate](https://stackoverflow.com/q/49864570/3890673), see my answer [here](https://stackoverflow.com/a/58928950/3890673) – crusy Nov 19 '19 at 07:49

0 Answers0