Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pushing to GitLab repo does not trigger the Jenkins build

gitlab plugin Version: 1.4.2

jenkins Version: 2.7.4

gitlab Version: GitLab Community Edition 8.11.4

I have followed the plugin documentation and setup the webhook accordingly

(https://github.com/jenkinsci/gitlab-plugin).

  • Added gitlab repo to the jenkins job, the connection test succeeds. Building the jenkins job manually also succeeds (The code is fetched from the repo correctly so no issues there)

  • Added the webhook for jenkins. Testing the webhook also succeeds (returns HTTP200). But on the jenkins side. nothing happens as a result of the test even after it was performed after a change to the repo (the jenkins log and gitlab plugin log show no activity)

  • When I try to test the whole setup. I make a new push to the gitlab repo to see if it triggers a new build on jenkins. But nothing happens. Can anybody help me out with this? I am not sure what is wrong here as both the test hook and test gitlab connection show success.

Thankyou in advance.

Naveed

like image 561
Naveed Haider Avatar asked Oct 04 '16 13:10

Naveed Haider


People also ask

Why Jenkins build is not triggering?

If the Jenkins job does not trigger, start by checking the logfile for any exceptions. Next, ensure everything is working correctly, confirm the following points: Polling SCM is enabled (no schedule is necessary, so that field can be left empty) Refer to Git plugin for instructions.


2 Answers

In Jenkins you install and configure (global and job) Gitlab Hook Plugin

in your webhook can you make this :

URL : http://your-jenkins-server/gitlab/notify_commit or http://your-jenkins-server/gitlab/build_now.

Trigger : you check Push Events

and try again

To trigger a specific job the URL is: http://your-jenkins-server/gitlab/build_now/job_name

job_name is the name of the job created in jenkins

like image 60
Inforedaster Avatar answered Sep 30 '22 13:09

Inforedaster


I followed the instructions here and everything worked quite well: https://github.com/jenkinsci/gitlab-plugin/wiki/Setup-Example. It is possible to give back the results of the jenkins job to GitLab pipelines.

You can also push back the results using the jenkins pipeline:

node {
  gitlabBuilds(builds: ['Build', 'Test', 'QA']) {
    stage('Build') {
      gitlabCommitStatus(name: 'Build') {
          sh "your execution"
      }
    }
    // The rest of the stages here...
  }
}
like image 40
Carlos Cavero Avatar answered Sep 30 '22 15:09

Carlos Cavero