There seem to be a lot of examples to poll GitHub but how can I poll Docker Hub and trigger a build based on that?
I've got a webhook set up in Docker Hub for my automated build but I can't see how to poll for it in Jenkins.
There seems to be this Jenkins plugin: https://wiki.jenkins-ci.org/display/JENKINS/DockerHub+Plugin
But, as I understand it the plugin has been broken since an API change on Docker Hub.
Update:
It seems that the answer is to use the Trigger Builds Remotely option under Build Triggers however it fails due to anonymous not having build permissions. Then I switched to using this plugin: https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin
So the URL becomes something like this: https://jenkinsserver.com/buildByToken/build?job=test&token=test
That works if I POST to that URL via a browser (even incognito) but not with cURL. I get:
$ curl -X POST https://jenkinsserver.com/buildByToken/build?job=test&token=test
<html><head><meta http-equiv='refresh' content='1;url=/securityRealm/commenceLogin?from=%2FbuildByToken%2Fbuild%3Fjob%3Dtest'/><script>window.location.replace('/securityRealm/commenceLogin?from=%2FbuildByToken%2Fbuild%3Fjob%3Dtest');</script></head><body style='background-color:white; color:white;'>
Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:
Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->
</body></html>
However, I can get it to work via cURL if I do this:
curl -X POST https://user:[email protected]/buildByToken/build?job=test&token=test
But, Docker Hub doesn't like that URL...
What am I missing here? Am I even on the right track? If you are someone who triggers and Jenkins task from a Docker Hub webhook, how do you do it?
Not sure if this is relevant yet, but the solution would be to invoke the url like this:
http://user:token@jenkins:8080/job/my-job/build?token=secretToken
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With