Gitlab webhook does not trigger a build on jenkins

前端 未结 4 1418
野的像风
野的像风 2021-02-07 07:39

I\'ve a group of multibranch pipeline jobs generated with the following piece groovy script:

[
      \'repo1\',
      \'repo2\',
].each { service ->

  multib         


        
4条回答
  •  悲&欢浪女
    2021-02-07 07:49

    I found this very useful Setup Example (Continuous Integration with Jenkins and GitLab) . Especially the part Source Code management:

    We need to specify the name as “origin”, which will be used by the other sections. For the Refspec we need to input: +refs/heads/*:refs/remotes/origin/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/*

    And also:

    Branch Specifier we need origin/${gitlabSourceBranch} which will be filled in based on the web hook we’ll be setting up next.


    Edit1

    You could try the following for one multibranch pipeline:

    1. Select a branch, for example ci
    2. Select "View Configuration"
    3. Under "Build Triggers" select the checkbox "Build when a change is pushed to GitLab"
    4. Make some changes to the code and push to ci

    Edit2

    I could not find a suitable git-project to run and try to reproduce this behaviour. So if someone know a similar project and could share, please comment and I could do some more testing.

    For Gitlab (requested a trial key, otherwise it will be a GitLab Community Edition):

    sudo docker run --detach --hostname gitlab.example.com --publish 443:443 --publish 80:80 --publish 22:22 --name gitlab --restart always --volume /srv/gitlab/config:/etc/gitlab --volume /srv/gitlab/logs:/var/log/gitlab --volume /srv/gitlab/data:/var/opt/gitlab gitlab/gitlab-ee:11.8.1-ee.0
    

    For Jenkins:

    sudo docker run  -u root  --rm  -d  -p 8080:8080  -p 50000:50000  -v jenkins-data:/var/jenkins_home  -v /var/run/docker.sock:/var/run/docker.sock  jenkins/jenkins:2.150.3
    

    Then "Integration" —> "Jenkins CI" in Gitlab as in this image:

    Hope this can help you!

提交回复
热议问题