似乎有很多例子可以轮询GitHub,但是我如何轮询Docker Hub并根据它来触发构建呢?
我在Docker Hub中设置了一个用于自动构建的webhook,但我无法在Jenkins中查看如何进行轮询。
似乎有这个Jenkins插件:https://wiki.jenkins-ci.org/display/JENKINS/DockerHub+Plugin
但是,据我了解,自从Docker Hub上的API更改后,该插件已被破坏。
更新
似乎答案是使用“构建触发器”下的“远程触发器构建”选项,但由于匿名没有构建权限,它会失败。然后我切换到使用这个插件:https://wiki.jenkins-ci.org/display/JENKINS/Build+Token+Root+Plugin
因此,网址变为:https://jenkinsserver.com/buildByToken/build?job=test&token=test
如果我通过浏览器(甚至是隐姓埋名)发布到该URL,但是没有使用cURL,那么这是有效的。我明白了:
$ 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>
但是,如果我这样做,我可以通过cURL让它工作:
curl -X POST https://user:token@jenkinsserver.com/buildByToken/build?job=test&token=test
但是,Docker Hub并不喜欢那个URL ......
我在这里缺少什么?我是否走在正确的轨道上?如果你是一个触发和来自Docker Hub webhook的Jenkins任务的人,你怎么做?
答案 0 :(得分:2)
不确定是否与此相关,但是解决方案是像这样调用url:
http://user:token@jenkins:8080/job/my-job/build?token=secretToken
答案 1 :(得分:0)
作者的话: 这个插件中的开发确实处于休眠状态,但可以在任何时候恢复,特别是在具体的用例中。当DockerHub挂钩被宣布时,我创建了这个插件作为PoC,但没有具体使用它来进一步实验。 随意贡献,以便插件可以支持您自己的使用。