如何从没有jenkinsfile的存储库中触发Jenkins管道构建? [英] How can I have a Jenkins pipeline build be triggered from a repository with no jenkinsfile?

查看:161
本文介绍了如何从没有jenkinsfile的存储库中触发Jenkins管道构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的存储库不包含 Jenkinsfile -无法影响存储库本身.这意味着我既不能在存储库中添加文件,也不能在存储库中更改任何文件(在这种情况下,其

I have a repository that does not contain a Jenkinsfile - and I have no way of influencing the repository itself. This means I can neither add nor alter any files to or in the repository (In this case, its the Qt repo).

我想做的是创建多个Jenkins文件,每个文件都针对不同的目标配置和构建Qt库,或者运行不同的其他脚本.
所有这些Jenkinsfiles都将收集在另一个存储库中.

What I want to do is create multiple Jenkinsfiles, that are each configuring and building the Qt library for a different target, or run different additional scripts.
All these Jenkinsfiles will be collected in a different repository.

现在,我的问题是如何创建管道作业,一旦Qt存储库中发生更改,该作业就会被触发,但是会使用另一个存储库中的Jenkinsfile.

Now, my problem is how to create a pipeline job, that gets triggered, as soon as there are changes in the Qt repository, but uses a Jenkinsfile from the other repository.

研究离开了我-据我所知,并按照进行 这些 帖子-有两个选项:

Research left me - as far as I can see and according to these posts - with two options:

  • 将两个存储库都添加到定义"部分-类似以下内容:
    不幸的是,这对我不起作用,因为两个存储库仍需要一个Jenkinsfile.此外,我无法为每个存储库指定不同的分支,因此无法侦听特定的Qt版本分支.

  • Adding both repositories to the Definition section - something along the lines of this:
    Unfortunately, this does not work for me, as both repositories would still need a Jenkinsfile. Further, I cannot specify a different branch for each repository, so I cannot listen to a specific Qt Version branch.

我看到的第二个(很可能是唯一的)选项是创建一个自由样式的Jenkins作业,该作业仅侦听Qt存储库,并在更改时触发构建管道作业,这是其唯一的动作.

The second (well, probably the only) option I see, would be to create a freestyle Jenkins job, that solely listens to the Qt repository and triggers a build of the pipeline job on a change as its only action.

我认为,第二种方法对我有用,但是我想知道的是,是否有任何插件,配置选项或者我错过的任何可以更干净地解决此问题的方法,或者以上是否是做到的方式.

I reckon, that the second approach would work for me, but what I want to know, is whether there is any plugin, configuration option or whatever that I missed that can solve this in a cleaner way, or whether the above is the way to do it.

推荐答案

为什么不使用常规的投票SCM"方法创建Jenkins Freestyle Job来监控QT回购?

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

然后让Freestyle作业启动一个或多个Jenkins管道作业.

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

您将使管道作业指向管道"jenkinsFile" groovy脚本所在的SCM(您控制的存储库).

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

在管道代码中,您可以使用管道SCM DSL步骤从Qt存储库(不受您控制的代码)中提取代码,然后进行所有构建,测试或其他操作.

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.

您可以将Qt Repo的URL和修订版作为轮询作业的参数传递到管道中.

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

这篇关于如何从没有jenkinsfile的存储库中触发Jenkins管道构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆