How to run tasks/promotions on jenkins pipeline builds? - jenkins

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

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

What is the difference between Build pipeline and Delivery pipeline in Jenkins?

I would appreciate if anyone could briefly point out what the difference between Build and Delivery pipelines in Jenkins? Are they the same with different producers?
I don't have a depth knowledge of both plugin but from my experience, the subtle difference between the Delivery Pipeline Plugin and Build Pipeline Plugin is that the first one allows you to use Freestyle Jobs and Pipeline Jobs while the second one only allows Freestyle Jobs.
So if you're using Shared Libs for your pipelines and want to use any of this plugins to have an overview of downstream and upstream Jobs you should definitely go for Delivery pipeline plugin
Build Pipeline Plugin:
https://plugins.jenkins.io/build-pipeline-plugin/
Delivery Pipeline Plugin:
https://plugins.jenkins.io/delivery-pipeline-plugin/

How to add multiple Jenkins jobs as a build parameters in single Jenkins job

->I have around 20 jobs which needs to be deployed parallel
I want to trigger these 20 jobs from single jenkins job.
I need to use those 20 jobs as build parameters in single jenkins job so i can choose which job to deploy.
Can someone help me with this requirement if there is any plugin or workaround?
I tried below options:
Active choices plugin and build flow plugin are not compatible with the current jenkins version 1.642 which i am using.
Multijob project can only deploy all jobs at once parallel but doesn't give any option/condition to run particular job.
Currently i am working on multijob phase project jenkins
I am trying to use some conditions in Multijob phase project but jobs not triggered as expected, If someone knows using conditions in multijob phase please lemme know
Thank you

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

How can the jenkins build can be discarded if no download stream is triggered?

There are two jobs in my jenkins server
job1 : build every 10 minutes to scan the events, if happens it triggers the downstream job2
job2 : normal job mostly run once in the case.
Problem:
too many useless jenkins build for job1 in the UI since it runs frequently.
It will be good if the build can be discarded if it doesn't trigger the downstream job.
Solution so far:, using Discard Old build plugin in post build action is one direction, but no clue how to get it works nicely.
With the hints from #JamesD's comments, I can use several plugins to achieve this
Archive artifacts Plugin: to archive the param.txt files which is used to path to downstream jobs
Groovy Postbuild job Plugin: add the groovy script to check whether the param.txt exists or not. The build will be set to Abort if it doesn't exists
Discard Old Builds Plugin: will discard the Abort build

Resources