Best way of creating multiple pipelines in Jenkins? - jenkins

I am actually implementing the continuous integration pipeline of the company I am working for with the help of Jenkins.
What I have done so far is a bit basic:
Create as many jobs as stages in my pipelines and then Build a pipeline view with the jobs I created before. So far so good but just for the test pipeline I have created.
I mean, this pipeline runs over a project. If I want to apply the same 'pipeline actions' against other project, I have to create again all jobs that are within the pipeline > create the Build a pipeline view and I will have another pipeline.
I am trying to extrapolate this into the Jenkins a code concept so that my pipeline will be formed by groovy code and the only thing left to do would be change the name of the project.
What do you guys think about my approach on building Jenkins pipelines?
Cheers,
Sebastian

Related

Jenkins Pipeline - Can we run a job outside of jenkins pipeline?

I am using jenkins pipeline and my Jenkinsfile has several stages and jobs. Is there any way to run specific job outside of jenkins pipeline ?
Example: Let's say one of the stage is to do "scp build artifacts to remote location". For some reason this got failed and if at all I want to run rest of the jobs manually out of jenkins pipeline, how can I do that ?
I am least interested to invoke a new build. So can we run remaining jobs after failure outside of jenkins pipeline manually ?
You may be able to do it by writing unit test cases to your Jenkinsfile and test them as a maven project. This may or may not solve your problem without looking at your entire problem but if you can reorganize your logic to achieve 100% test coverage then it is doable. You can find more information about writing test cases of Jenkins pipelines here

Multiple GitHub Checks with Jenkins Multibranch pipeline

I have configured Jenkins using Blue ocean multibranch pipeline and a Jenkinsfile to trigger a build when new pull request appear in a repo.
In this pipeline I have two stages that run in parallel, because they are independent tests. What I would like to achieve is to display two check results on the pull request page on Github, one for each stage.
Initially I though about creating two pipelines using two different Jenkinsfile, but it seems that multibranch plugin does not support this.
What is the correct solution to achieve this?
You can use plugin - https://github.com/jenkinsci/github-autostatus-plugin
The plugin can be configured to send commit status for each stage for jobs build from a multibranch project. For example:

Allow promotion of job in Jenkins pipeline

I have a Jenkins pipeline which is responsible for about 5 stages (build and several different tests). I'm migrating from Jenkins 1.XX (with no pipelines) to Jenkins 2 and I'd like to replicate my process as closely as possible. The pipeline job I have set up on J2 handles everything exactly the same except it's using a JenkinsFile. The only issue is that the pipeline plugin does not appear to support Promotion of particular builds like you can do with Freestyle Jobs. Has anyone found a way around this?
Seems like Promoted Builds Plugin doesn't support pipelines yet. If you check the issue there is also some good pros and cons about supporting it for pipelines.

Jenkins pipeline using upstream and downstream dependency

I had some jenkins standalone jobs to build, package and deploy. Now I am connecting them and making 'build' job trigger 'package' job , and 'package' job to trigger 'deploy' job and am passing the required parameters between them.I can also see them neatly in pipeline view.
My question is, can this technically be called a pipeline? Or can I call it a pipeline only if I use pipeline plugin and write groovy script?
Thanks
p.s: Please do not devote this question. It is a sincere question for which I am not able to find the right answer. I want to be technically correct.
In Jenkins context, a pipeline is a job that defines a workflow using pipeline DSL (here, based on Groovy). A pipeline aims to define a bunch of steps (e.g. build + package + deploy in your case) in a single place, allows to define a complex workflow (e.g. parallel steps, input step, try/catch instructions) that can be both replayed and versionned (because it can be saved to git). For more information you should read Jenkins official pipeline documentation that explains in details what a pipeline is.
The kind of jobs you are currently using are called freestyle jobs, and even if they do define a "flow" (by chaining jobs together), they cannot be called pipelines jobs.
In short, pipelines are jobs that use pipeline plugin and groovy script syntax to define the whole application lifecycle, and standard Jenkins 1.x jobs are called freestyle jobs.

Creating tasks as part of a build in Jenkins

I currently have a project set up in Bamboo that has various tasks attached to it ranging from: source code checkouts, scripts and commands.
I would like to transition over to Jenkins and perform the same action and found that Pipelines may be what I am looking for.
Can anyone provide me with a basic understanding of how I can create a Pipeline or freestyle job in Jenkins with sequential tasks that are executed as part of a build? A project in Bamboo has a plan with various tasks and I would like to replicate the same thing in Jenkins.
Here is an example of what my Bamboo tasks look like:
Thanks

Resources