jenkins-gitlab-merge-request-builder-plugin icon indicating copy to clipboard operation
jenkins-gitlab-merge-request-builder-plugin copied to clipboard

MR happens OK, but the job always build from the very first version of main repo.

Open uhmfa opened this issue 10 years ago • 4 comments

Versions:

  • Gitlab 7.14
  • Gitlab Merge Request Builder Plugin 1.2.4
  • Jenkins 1.633

So, no updates happens on jenkins workpsace's working copy after the MRs, so it always build using the very first version of the main repo. I can't see how to make Jenkins pull the repo before running a new job. And a related doubt: Is Jenkins actually building in order to validate the MR? I would expect it to merge the fork to the main in a temp branch, build the resulting code, and if OK, merge to main repo, or else reject the MR. Am I wrong? Thanks in advance.

BTW log of a MR job:

en-compiler-plugin:3.1:testCompile (default-testCompile) @ my-app --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ my-app --- [INFO] No tests to run. [JENKINS] Recording test results [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my-app --- [INFO] Building jar: /var/lib/jenkins/jobs/appli/workspace/target/my-app-0.1.0.jar [INFO] [INFO] --- maven-shade-plugin:2.1:shade (default) @ my-app --- [INFO] Including joda-time:joda-time:jar:2.2 in the shaded jar. [INFO] Replacing original artifact with shaded artifact. [INFO] Replacing /var/lib/jenkins/jobs/appli/workspace/target/my-app-0.1.0.jar with /var/lib/jenkins/jobs/appli/workspace/target/my-app-0.1.0-shaded.jar [INFO] Dependency-reduced POM written at: /var/lib/jenkins/jobs/appli/workspace/dependency-reduced-pom.xml [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.973 s [INFO] Finished at: 2015-11-03T16:39:11+01:00 [INFO] Final Memory: 16M/40M [INFO] ------------------------------------------------------------------------ [JENKINS] Archiving /var/lib/jenkins/jobs/appli/workspace/dependency-reduced-pom.xml to org.springframework/my-app/0.1.0/my-app-0.1.0.pom [JENKINS] Archiving /var/lib/jenkins/jobs/appli/workspace/target/my-app-0.1.0.jar to org.springframework/my-app/0.1.0/my-app-0.1.0.jar channel stopped Finished: SUCCESS

uhmfa avatar Nov 03 '15 15:11 uhmfa

Hey @fedealaimo I encounter the same issue: when using GitLab Merge Request Builder with MR from forks, it always build the very first revision it builds. When I use it without forks (with 2 branches of the same repo) it works.

I found a workaround for the MR of forks: in your Jenkins job, in SCM > Git > Advanced, you can set "Choosing strategy" > "Inverse" and then it build the last commit of both branches.

Could you check it please ?

pfrayer avatar Nov 20 '15 14:11 pfrayer

Hello @pfrayer, Thanks for your suggestion. I tried this but now it builds both the fork and the central, which leads to problems. For instance, if my fork has an issue and the build fails, when I ask for a MR, jenkins launches 2 jobs. One for the main repo and one for the fork. If the main one's goes first (seems to pick up randomly) it passes OK and it merges the fork, before building the fork thus merging a broken code. This is not what I want. I would like it to only build the fork, and only if it passes OK, merge to the main repo, otherwise reject it.

uhmfa avatar Nov 23 '15 09:11 uhmfa

The workaround that seems to make it: Setp up a Pre Step: "Execute shell" --> Command: cd /var/lib/jenkins/jobs//workspace forked=$(echo $gitlabSourceRepository|cut -d":" -f2|cut -d"." -f1) git checkout remotes/$forked/$gitlabSourceBranch

This will pull the forked repo and build it. Tested ok on both cases:

  1. A new MR launches a jenkins job: build OK -> MR passed
  2. A new MR launches a jenkins job: build failed -> MR rejected. Then code fixed and MR reopened launches another job: and build OK -> MR passed.

uhmfa avatar Nov 23 '15 14:11 uhmfa

I’m facing the same issue: MR are always built from first version even on the same repo.

Frogger2 avatar Oct 27 '16 13:10 Frogger2