How to make Jenkins build something on pushing to GitHub?

368 views
Skip to first unread message

Yuri Kanivetsky

unread,
Mar 21, 2017, 3:52:30 PM3/21/17
to Jenkins Users
Hi,

I have a pipeline job. It has "GitHub project" checked in settings. Project url is specified. And "GitHub hook trigger for GITScm polling" is checked in Build Triggers. I can see notifications coming from GitHub in System Log:

Mar 21, 2017 7:23:28 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber onEvent
Mar 21, 2017 7:23:28 PM INFO org.jenkinsci.plugins.github_branch_source.PushGHEventSubscriber onEvent

The job has hello world pipeline. Jenkins master node is running in lxc container, if anything. And doesn't have slave nodes. But when I click "Build Now" it sort of builds. I'm running Jenkins 2.32.3. Also, I fixed Jenkins complaining about being run behind proxy, or something along those lines.

How do I make it build when pushing to GitHub repository? What do I check?

Project url matches what's in the log, except for trailing slash. But when I try to remove it, it reappears.

Regards,
Yuri

Cuong Tran

unread,
Mar 21, 2017, 10:47:24 PM3/21/17
to Jenkins Users
Your job need to have a scm configuration for it to be triggered on commits.  Either configure it as Multibranch Pipeline job or add a "git" or checkout step in your normal pipeline.

arseni...@gmail.com

unread,
Mar 22, 2017, 11:57:09 AM3/22/17
to Jenkins Users
http://stackoverflow.com/questions/30576881/jenkins-build-when-a-change-is-pushed-to-github-option-is-not-working

вторник, 21 марта 2017 г., 20:52:30 UTC+1 пользователь Yuri Kanivetsky написал:

Yuri Kanivetsky

unread,
Mar 23, 2017, 2:31:39 AM3/23/17
to Jenkins Users
Your job need to have a scm configuration for it to be triggered on commits.  Either configure it as Multibranch Pipeline job or add a "git" or checkout step in your normal pipeline.
 
Can you elaborate on 'add a "git" or checkout step in your normal pipeline' part? I tried it with this pipeline:

node {
    git credentialsId: 'b22c8273-0293-8364-2463-233ab3898fe', url: 'g...@github.com:USER/REPO.git'
    echo 'Hello World'
}

I can see notification from GitHub coming in Jenkins' System Log, but build doesn't get triggered.

In the pipeline I created I checked "GitHub project", filled in the "Project url" text field (e.g., https://github.com/rails/rails), and checked "GitHub hook trigger for GITScm polling".

Ramanathan Muthaiah

unread,
Jun 2, 2017, 4:24:50 AM6/2/17
to Jenkins Users
Hello Yuri,

Am in an identical situation. Were you able to nail this issue? 

/Ram

Yuri Kanivetsky

unread,
Jun 2, 2017, 12:12:26 PM6/2/17
to Jenkins Users
Hi,

Yep, I switched to Multibranch pipeline. You can find my "report" here: https://stackoverflow.com/a/42968421/52499 But I haven't finished setting up Jenkins. But at least it now starts the build when new commits come.

Regards,
Yuri
Reply all
Reply to author
Forward
0 new messages