Jenkins Multi-Configuration Job to Pipeline - jenkins

I have a multi-configuration job that has a custom axis for each of our clients, with the selected values determining which config file is used in the build steps.
I'm trying to setup a pipeline to mimic this job but I can't seem to figure it out.
The choice parameter is a single choice only, and the plugin Extended Choice Parameter is suffering from various security issues and hasn't been updated in some time.
Is there a way I can achieve my multi-configuration job in pipelines without using Extended Choice Parameters?
So I need a list of values (client names) that I can select all or some, and have the build run for each selection.

Related

Multibranch pipeline per-branch parameters

I have a build job on Bamboo that has parameterized branches. All branches (for e.g. feature branches created by developers at will) have a default set of parameters, and specific branches override some of them. Note that once I set a variable for a given branch to a certain value, every build of that branch takes that value. I'm trying to recreate this in Jenkins, but there doesn't seem to be a way to do so.
I created a multibranch pipeline and defined the parameters in my Jenkinsfile with suitable defaults. However, the only way I can override the parameters for a branch is to click "Build with parameters" and update them. That works for that build, but next build that gets triggered reverts back to using the default values. This seems like such a basic use case that I feel like I must be missing something or misconfigured the project somehow, considering I don't have any experience using Jenkins before trying this. Thanks in advance for your help!

Jenkins Multibranch Pipleine: set _job_ name from Jenkinsfile

Short: Can I set the name of a Jenkins job created automatically by the Multibranch Pipeline job, to something calculated in the job itself?
Long:
We do a lot of microservices with mostly identical build processes, and we would like to have as little hassle building and testing them as we can.
To that end, I am considering the Jenkins Multibranch Pipeline jobs, where I could just add another project repository and have that new repository built with new jobs being created for new branches that contain Jenkinsfiles. That would also cause the new jobs appear on the build monitor. And here is where the problems start.
I would like to see the name of the project on the build monitor cells, rather than something like my_multibranch_pipeline_t ยป temp_branch_one. However, I couldn't find a way to set the JOB_NAME to anything.
Am I missing something?
I really don't know any way to set the job name from the Jenkinsfile. However we solve the same issue that you describe using seedjobs. These are basically freestyle jobs executing Jenkins' Job DSL, which is able to define as many jobs as you like.
We are using a map of service names, mapped to their Git-urls and iterate over that using Groovy's each.

Jenkins Multibranch Config: How to Filter branches based on variable string?

We have Jenkins set up with 7 multibranch pipeline projects, each building off the same git repo, but for different target platforms. Each of these multibranch pipelines builds a number of branches. We currently set which branches each multibranch pipeline builds by using the following property in the multibranch project configuration:
Branch Sources -> Git -> Behaviors -> Filter by name (with wildcards)
Currently, each multibranch pipeline has the same string of branches in this Filter by name (with wildcards) field. Each time we want Jenkins to start building a new branch, we go through all 7 multibranch project configurations and update this field to include the new branch.
It's a bit of a pain to go through each configuration and change this field every time, since we always want each configuration to have the same list of branches. Is it possible to simply use some type of a variable in this field? This way we only would need to change one location instead of trying to keep 7 different configurations in sync with each other, which is prone to error and also a bit of a pain.
Thanks for your help!
Allen
Rather than filtering with wildcards, you could try filtering branches with regular expression. In our case, pattern like:
(master|develop|release.*|feature.*|bugfix.*)
has been working well to cover the repository. That is, assuming that you follow Git Flow or similar methodology. Unfortunately, there is no simple way to sync the configuration between MultiBranch Pipelines build from one repository. Neither Multibranch Pipeline, nor Organization plugins are designed to work with Multiple Jenkinsfiles.
Also, you can try to sync only the branch configuration between Projects using Jenkins script console. Most of the Job configuration does not have to be set on Project level. For instance, you can create shared script (or shared library) to would be sourced by other jobs, to set the same job properties on each of them. See How do you load a groovy file and execute it for details.
if you want to use the wildcard you can provide like below:
In this example it will discover only qa and dev branch.
NOTE: You have to use "Discover branches" also with "filter by name (with wildcards)" behaviour.

How to create paramiterized jenkins job using script?

I want to automate the process of creating jenkins job and want to trigger a script that will automatically create a job with certain set of required parameter. One way I exploreed is using DSL and parameterized trigger plugin.
As far as my observation over it-
Parameterized Trigger Plugin- used trigger new builds when one build has completed, with various ways of specifying parameters for the new build.
DSL Plugin- Allows the programmatic creation of projects using a DSL.
My requirement is to write a script that create a job with some parameters like string or choice parameters including Source Code Management configuration and build trigger specification.
Any input is appreciated :)

Is it possible to have multi-config template in Jenkins?

I have a number of multi-config jobs and all have to run on the same machines, one after another.
For example:
Build on all platforms.
Do some automated testing.
Do some automated benchmarking.
These are all happening on the same machines, in that order, but they are different jobs.
The problem is that if I want to add another platform or remove one of them, I will have to do it for every single multi-config job. What I would like is to have a way of defining those platforms in one place and then have the jobs point to that template and run.
I am quite sure I'm not the first one to hit this problem and that there should be some plugin out there, but I haven't been able to find it.
So, is there any simple way of doing this?
We create temaplte jobs in jenkins which helps us to create all the set of jobs reqired for a platform, we just pass the platform / component name as input pareamter for the template job. We us the job copy plugin https://wiki.jenkins-ci.org/display/JENKINS/Jobcopy+Builder+plugin
But for a deleting the jobs we have another job where again the component name is the input parameter and we use something similar to the answer given here Is it possible to delete a hudson job programmatically via REST API?

Resources