Discussion:
Secure Jenkins and mutlibranch github pipeline trigger
Lionel Orellana
2016-05-07 02:29:22 UTC
Permalink
Hi All

How can I trigger a build on a multibranch pipeline where there is a push
in github and Jenkins requires authentication.

I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a webhook
like <jenkins_url>/job/<job name>/build?token=some token where the token
matches what's in the "Trigger builds remotely" configuration.

Thanks

Lionel.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/626e3f75-bb73-4523-a07a-adc57b589d25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lionel Orellana
2016-05-07 02:52:12 UTC
Permalink
Sorry found my answer. Nothing to do with pipeline.

http://<user>:<user token>@<jenkins_url>/job/<job name>/build?token=job
token
Post by Lionel Orellana
Hi All
How can I trigger a build on a multibranch pipeline where there is a push
in github and Jenkins requires authentication.
I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a
webhook like <jenkins_url>/job/<job name>/build?token=some token where
the token matches what's in the "Trigger builds remotely" configuration.
Thanks
Lionel.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/55283fad-2948-47f8-8938-e33951d7c94a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lionel Orellana
2016-05-07 04:17:01 UTC
Permalink
Actually something's not quite right.

Firstly, the configuration in the Multibranch project to "Trigger builds
remotely" disappears after I save. Select the option, put a token, save and
reopen. They are gone.

Secondly, assuming the configuration is actually saved, the url to trigger
the build needs to have the branch name in it:

<jenkins_url>/job/<job name>/branch/master/build?token=some token

This actually works (despite the config seemingly not being saved). But
without the branch name in the url it doesn't do anything. So do I have to
setup a different webhook for each branch?

It feels like this should work out of the box and I'm doing something very
silly.



And yet, invoking the url with curl triggers the build. Seems like a UI
problem.
Post by Lionel Orellana
Hi All
How can I trigger a build on a multibranch pipeline where there is a push
in github and Jenkins requires authentication.
I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a
webhook like <jenkins_url>/job/<job name>/build?token=some token where
the token matches what's in the "Trigger builds remotely" configuration.
Thanks
Lionel.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/78ab11b0-4df2-47a2-8153-a2c51ab1fc7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lionel Orellana
2016-05-07 04:21:21 UTC
Permalink
Invoking without the branch name in the url triggers the indexing job of
course. So it seems I need a different webhook per branch?
Post by Lionel Orellana
Actually something's not quite right.
Firstly, the configuration in the Multibranch project to "Trigger builds
remotely" disappears after I save. Select the option, put a token, save and
reopen. They are gone.
Secondly, assuming the configuration is actually saved, the url to trigger
<jenkins_url>/job/<job name>/branch/master/build?token=some token
This actually works (despite the config seemingly not being saved). But
without the branch name in the url it doesn't do anything. So do I have to
setup a different webhook for each branch?
It feels like this should work out of the box and I'm doing something very
silly.
And yet, invoking the url with curl triggers the build. Seems like a UI
problem.
Post by Lionel Orellana
Hi All
How can I trigger a build on a multibranch pipeline where there is a push
in github and Jenkins requires authentication.
I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a
webhook like <jenkins_url>/job/<job name>/build?token=some token where
the token matches what's in the "Trigger builds remotely" configuration.
Thanks
Lionel.
--
You received this message because you are subscribed to a topic in the
Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/jenkinsci-users/Jv2V4tldkFs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/78ab11b0-4df2-47a2-8153-a2c51ab1fc7a%40googlegroups.com
<https://groups.google.com/d/msgid/jenkinsci-users/78ab11b0-4df2-47a2-8153-a2c51ab1fc7a%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO-n44OQOLm_O1Ai6MaVyUm5oJZ0JChJyoZJc9Se6mNwO6o86g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Lionel Orellana
2016-05-07 06:38:48 UTC
Permalink
Well seems like the solution would for the GitHub Plugin to support
Multibranch pipelines
Post by Lionel Orellana
Hi All
How can I trigger a build on a multibranch pipeline where there is a push
in github and Jenkins requires authentication.
I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a
webhook like <jenkins_url>/job/<job name>/build?token=some token where
the token matches what's in the "Trigger builds remotely" configuration.
Thanks
Lionel.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/20857378-40b9-4ffb-b2d6-f8fcb7cae005%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lionel Orellana
2016-05-09 13:08:52 UTC
Permalink
Apologies for my rather disorganised thought process in this thread.

I just found the 'Re-register hooks for all jobs' in the global config
(GitHub Servers Advanced options). That created the hooks correctly for me
without any additional configuration in the multibranch job.

Thanks.
Post by Lionel Orellana
Well seems like the solution would for the GitHub Plugin to support
Multibranch pipelines
Post by Lionel Orellana
Hi All
How can I trigger a build on a multibranch pipeline where there is a push
in github and Jenkins requires authentication.
I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a
webhook like <jenkins_url>/job/<job name>/build?token=some token where
the token matches what's in the "Trigger builds remotely" configuration.
Thanks
Lionel.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9d64a0bd-c50b-4eff-ae8b-dc303732cdee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Corey Wei
2016-10-06 05:49:11 UTC
Permalink
Hi Lionel,

I just tested this on Jenkins 2.19.1.
Looks like "Re-register hooks for all jobs" is not working for my
multibranch job. Is there anything I am missing?

Thanks
Post by Lionel Orellana
Apologies for my rather disorganised thought process in this thread.
I just found the 'Re-register hooks for all jobs' in the global config
(GitHub Servers Advanced options). That created the hooks correctly for me
without any additional configuration in the multibranch job.
Thanks.
Post by Lionel Orellana
Well seems like the solution would for the GitHub Plugin to support
Multibranch pipelines
Post by Lionel Orellana
Hi All
How can I trigger a build on a multibranch pipeline where there is a
push in github and Jenkins requires authentication.
I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a
webhook like <jenkins_url>/job/<job name>/build?token=some token where
the token matches what's in the "Trigger builds remotely" configuration.
Thanks
Lionel.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/7d523677-1684-4d78-8c54-94c8ff5659d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Lionel Orellana
2016-10-06 09:46:52 UTC
Permalink
Hi Corey

Unfortunately I don't have this server running anymore. I was just using it
to learn stuff. But I do remember that re-registering hooks worked straight
away for me. Are you behind a firewall? I was running this on a cloud
provider with direct access from the outside world (e.g. from github.com)
When you say it doesn't work, what error or wrong behavior do you see?

Lionel
Post by Corey Wei
Hi Lionel,
I just tested this on Jenkins 2.19.1.
Looks like "Re-register hooks for all jobs" is not working for my
multibranch job. Is there anything I am missing?
Thanks
Post by Lionel Orellana
Apologies for my rather disorganised thought process in this thread.
I just found the 'Re-register hooks for all jobs' in the global config
(GitHub Servers Advanced options). That created the hooks correctly for me
without any additional configuration in the multibranch job.
Thanks.
Post by Lionel Orellana
Well seems like the solution would for the GitHub Plugin to support
Multibranch pipelines
Post by Lionel Orellana
Hi All
How can I trigger a build on a multibranch pipeline where there is a
push in github and Jenkins requires authentication.
I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a
webhook like <jenkins_url>/job/<job name>/build?token=some token where
the token matches what's in the "Trigger builds remotely" configuration.
Thanks
Lionel.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2af91f3c-6f77-4528-b2e6-2fd6becfb132%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Corey Wei
2016-10-08 13:37:47 UTC
Permalink
Hi Lionel,

It's working once I added the following to Jenkinsfile :
properties([pipelineTriggers([[$class: 'GitHubPushTrigger']])])

Thanks
Post by Lionel Orellana
Hi Corey
Unfortunately I don't have this server running anymore. I was just using
it to learn stuff. But I do remember that re-registering hooks worked
straight away for me. Are you behind a firewall? I was running this on a
cloud provider with direct access from the outside world (e.g. from
github.com) When you say it doesn't work, what error or wrong behavior
do you see?
Lionel
Post by Corey Wei
Hi Lionel,
I just tested this on Jenkins 2.19.1.
Looks like "Re-register hooks for all jobs" is not working for my
multibranch job. Is there anything I am missing?
Thanks
Post by Lionel Orellana
Apologies for my rather disorganised thought process in this thread.
I just found the 'Re-register hooks for all jobs' in the global config
(GitHub Servers Advanced options). That created the hooks correctly for me
without any additional configuration in the multibranch job.
Thanks.
Post by Lionel Orellana
Well seems like the solution would for the GitHub Plugin to support
Multibranch pipelines
Post by Lionel Orellana
Hi All
How can I trigger a build on a multibranch pipeline where there is a
push in github and Jenkins requires authentication.
I tried "Trigger builds remotely (e.g., from scripts)" but the token
generated here isn't enough for a github webhook to authenticate with
Jenkins. Github throws "Authentication required". This is using a
webhook like <jenkins_url>/job/<job name>/build?token=some token where
the token matches what's in the "Trigger builds remotely" configuration.
Thanks
Lionel.
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b9cf3400-2e42-491a-94d7-646375e11636%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...