Jenkins delivery pipeline view -how to add manual trigger(play button)? - jenkins

I am trying to connect/achieve below things:
Pipeline having job with multiple stages and tasks
Configure above pipeline with Delivery view plugin
Last task of last stage is to deploy to production [caution: want this task with manual trigger]
Jenkins version: 2.222.x
Things I tried
node {
stage 'Build'
task 'Compile'
echo 'Compiling'
sleep 1
task 'Unit test'
sleep 1
stage 'Test'
task 'Component tests'
echo 'Running component tests'
sleep 1
task 'Integration tests'
echo 'Running component tests'
sleep 1
stage 'Deploy'
task 'Deploy to UAT'
echo 'Deploy to UAT environment'
sleep 1
task 'Deploy to production'
echo 'Deploy to production, but wanted with manual trigger'
sleep 1
}
Below is the desired configuration which I am looking.
desired configuration, delivery pipeline plugin wiki
I could able to achieve that manual trigger by creating multiple free style jobs with upstream and downstream configuration and for the manual step I can set post build job with manual trigger.
But that is something which I want in pipeline because there we have task (inside stage also we can do separate vertical tasks)feature.
Please help me and suggest how to achieve this.

Related

How to trigger a job when one job is finished

I used this:
post {
always {
sh "echo Jenkins Job is Done"
junit 'target/surefire-reports/*.xml'
echo 'Run darkWeb Test pipeline!'
build job: 'DarkWeb'
}
and it works. The problem is that the original job continuing running while the second job (DarkWeb) is running too.
I want the 'DarkWeb' job to run only after the original job is completely finished
You can try the following syntax:
build job: 'Darkweb', wait: false
The wait: false token would allow the first job to finish without waiting for the completion of second job.
Let me know if it works!

Restart From A Failed Jenkins Pipeline Stage

In Jenkins, i have a pipeline with stages
checkout from git
compile create the binary
integrate tests which generate junit report xml
if stage 3 failed, I want to allow user to re-run stage 3 without stage 1, and 2. Currently, when I try to restart from stage 3 from Jenkins web gui, it reports the binary no longer exists. Look like some clean up process has been executed?
If you have multiple nodes or execute the pipeline concurrently Jenkins might not look in the same directory in which you compiled the binary. You can use the archiveArtifacts step in stage 2 and copyArtifacts in stage 3 for continuity (for performance considerations you can set a variable in stage 2 and run copyArtifacts only when it's not set in stage 3.)

How to trigger a task inside a job from jenkins pipeline

I have a Maven project that builds a war file and a separate batch task inside the build job to deploy it to a server (this is basically a shell script executed on Jenkins).
This is the pipeline script:
node {
stage('Build') {
build job: 'core UAT'
}
stage('Deploy') {
build job: 'core UAT'
}
Is there a way to specify something like:
stage('Deploy') {
build job: 'core UAT -> Deploy'
}
I suppose I could manually copy paste the batch task steps into the pipeline stage, but I want to trigger as if it was run explicitly.
This may help:
task screenshot

jenkins job does not finish even though it is successful

I have a Jenkins pipeline job in which I give a windows batch command to start my hybris server. Normally also if hybris is started from a command prompt, the server window (command window) will keep the process running and it does not exit. With the same thing happeining in Jenkins, the job never ends even though the server has successfully started. Pls suggest how I can get the server running, yet exit out of the job succesfully. Below is the pipeline script:
node {
stage 'ServerStop'
echo 'Stop the server if previously running'
bat '''call D:\\path_to_hybris\\hybris\\bin\\platform\\hybrisserver.bat stop
EXIT /B 0'''
stage 'Checkout'
echo 'Checkout related script'
stage 'Build'
echo 'Build script here'
stage 'ServerStart'
bat '''call D:\\path_to_hybris\\hybris\\bin\\platform\\start.bat
'''}

How to invoke Ant in Jenkins pipeline job using groovy script?

I am changing my Freestyle Jenkins job configuration to Pipeline. I need to Invoke Ant to perform LogPublisherTask and ArtifactFilePublisherTask. How is it performed using Groovy scripting?
You invoke ant just like you do it with maven (take a look at examples https://jenkins.io/doc/pipeline/jenkinsfile/):
node ('linux'){
stage 'Build and Test'
env.PATH = "${tool 'Ant'}/bin:${env.PATH}"
checkout scm
sh 'ant build'
}
The tasks themselves should be configured in the build.xml.

Resources