Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have a Jenkins pipeline build be triggered from a repository with no 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).

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.

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:

  • Adding both repositories to the Definition section - something along the lines of this:
    enter image description here 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.

  • 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.

like image 911
T3 H40 Avatar asked Dec 13 '16 08:12

T3 H40


1 Answers

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.

like image 172
macg33zr Avatar answered Oct 22 '22 01:10

macg33zr