How can I have a Jenkins pipeline build be triggered from a repository with no jenkinsfile?

老子叫甜甜 提交于 2019-12-05 05:03:24

Why don't you create a Jenkins Freestyle Job that monitors the QT repo using the regular "Poll SCM" method?

Then have that Freestyle job kick off one or more of your Jenkins pipeline jobs.

You would have the pipeline jobs point at the SCM where the pipeline "jenkinsFile" groovy scripts live (the repos you control).

Inside the pipeline code, you can use a pipeline SCM DSL step to pull code from the Qt repo (the one not under your control) then do all the building, testing or whatever.

You can pass the URL and revision of the Qt Repo into the pipeline as a parameter from the polling job.

Michael Lihs

Did you think about a webhook that triggers the Jenkins job from your Git server? This way you can have arbitrary repos trigger your build and reduce the traffic on the Git server caused by the periodic poll from Jenkins.

The principle behind it is that Jenkins provides a URL for your build job (e.g. http://your-jenkins.domain/job/JOBNAME/build?token=TOKEN) that starts your job. Git on the other hand can register a so called hook that is triggered whenever a push is made to the repository. Adding a HTTP request to your Git hook will trigger the Jenkins job every time someone pushes to your repository.

This SO Post explains how to set up such a hook with any Git server. There are also tutorials for Gitlab and Github.

You can configure a build trigger, to check if there are changes in the repository: Build Trigger -> Poll SCM. There you can configure a schedule:

For example * * * * * to check every minute or H * * * * to check hourly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!