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

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

Related

Ho do I restart the jenkins pipeline with an updated JenkinsFile

I have a Jenkins project with a declarative pipeline defined in a JenkinsFile stored in a SCM. I use the "Pipeline script from SCM" option.
Sometimes if something fails I do a quick fix in the jenkins workspace and rerun the pipeline starting at a specific stage. This is working nicely.
There are cases in which I need to update the JenkinsFile and then do a 'restart at stage' with the updated Jenkins file. However, I can't find the JenkinsFile anywhere in the workspace folder. I need to know the location so I can do a quick fix and then restart the pipeline. Where is the JenkinsFile located?
See "Replay" Pipeline Runs with Modifications:
The "Replay" feature allows for quick modifications and execution of an existing Pipeline without changing the Pipeline configuration or creating a new commit.

How to run tasks/promotions on jenkins pipeline builds?

Does anyone have a mechanism to simulate what the promoted builds plugin does or the batch tasks plugin does, but for pipeline builds?
I want to be able to for example, run the maven release plugin after a build, or as the promoted plugin allows, "promote" a build.
The best case scenario would be that the promoted builds plugin or the batch task plugin would take a pipeline as input...
Or possible allow me to call another job (optionally) once a build is finished - but then I would want that job to run on this result.
You can define pipelines at promotion time with this plugin :
https://wiki.jenkins.io/display/JENKINS/Promoted+Builds+Plugin

Is there any alternative for promoted builds in Jenkins

I am using Jenkins pipeline scripts for all my jobs. I was using Promoted-builds plugin for other jobs, But its not compatible with Pipeline scripts. Is there any alternative? .
Pipeline script has manual input but that does not solve the problem as the job is in build queue until the input is provided.
I have been using Hudson / Jenkins since 2007. I have never found the Promoted Builds plugin to be that useful.
Instead I use labels / tags from different jobs (Build and Unit Test, System Test, Performance Test) or artifact repositories as markers of where an version or artifact has progressed to in the overall "pipeline".
Regarding Artifactory:
In my Build and Unit Test job, on Success of the Integration branch I tag the source code and upload the tested artifact to Artifactory.
In my System Test job, on success I call my Performance Test job as a downstream job passing the version number of the successfully tested package as a parameter.
In my Performance Test job, on success I "copy-promote" the tested artifact to the next designated location in Artifactory.
HTH

Best way of creating multiple pipelines in 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

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.

Resources