How to add manual approver to Jenkins job - jenkins

I have a job that updates the databases for TEST servers and this job should be run by support after an approval from Account Manager
The job is parameterized and I need a way to pause build until the approver approves running the build
EX. When the support click on Build , an Email should be sent to the approver and whenever the approver responds to the link the job will start running.

I think you are asking a bit much here. Jenkins is a build tool rather than a change management tracker.
You can setup a manual approvals step e.g.
steps {
timeout(time: 1, unit: 'HOURS') {
input(message: "restart thes instance?", submitter: 'admin-team')
}
}
Where admin-team is an AD group referenced in an authorization strategy.
You also wouldnt get an email (you could set this up with more code), and the approver would have to login to Jenkins to check the button.
To do something like you are asking you would probably want to have Jira or something handle you approvals (e.g. move a ticket to approved), and that fires a webhook to start the Jenkins job.

Related

How to trigger a Jenkins job on a different Jenkins server from a Jenkins pipeline

It's easy enough to call one Jenkins job from another Jenkins job if they're both jobs on the same Jenkins instance:
pipeline {
agent any
stages {
stage('call the say_hello job') {
steps {
build 'say_hello'
}
}
}
}
But how do we do this if the 'say_hello' target Jenkins job is on a different Jenkins server than the calling job? (Not a different agent, I mean a completely different Jenkins instance managed by another group in my company.)
Right now we're doing it with calls to the Jenkins httpRequest plugin to trigger them, and then more httpRequest calls to poll the status of the remote job (so we can propagate their result states), but it feels a little kludgy and I was hoping there was a more robust way.
1) Enable the URL job trigger in destination job
2)Enable permission for “auto” in matix based security add auto and set permission accordingly
3) you’ll need to use an API token. From the user list, click on the “configure” icon (the wrench and screw driver) next to the “auto” user.
4)do curl in stage from original job http://auto:8702d1cb53a83f8748d9433ebca494fb#your-jenkins.com/job/JobName/build?token=iFBDOBhNhaxL4T9ass93HRXun2JF161Z
above url consist of api token , authentication token and user ( e.g. auto )

Jenkins Email notification for multiple builds

I need suggestion for Jenkins project (multi-conf or pipeline) and plugins that will fit my work.
I have 10 "flavors" of the product, so I must build 10 times every time I commit to the repository (all in the same workspace, run in sequentially). Today I have 10 jobs (freestyle) and a "master" job that trigger the rest. I tried to add Email notification (using Email Extension Plugin) but I want only one Email report for all the builds, not 10 Emails.
I understand that I should change to one multi-configuration project or one pipeline project that will handle all the builds, so it will be easier to trigger only one Email, but what is the best practice to get only one Email report on multiple builds?
This is the exact scenario which we can achieve using Pipeline job(Jenkinsfile) from which you can trigger all those freeStyle build-jobs in parallel and collect the build-url and build-status of those and store in some file, then use the email plugin in the post-build task to send the status of your complete flow.
You can use the following link to find how to access build variable post calling that inside your pipeline.
How to I get the url of build triggered with build step on Jenkins?

User prompt for downstream job

I would have job1 with one dropdown parameter - ENV (DEV, QA, etc) which run and download some files from git repo, and after this it should run job2 which has several another parameters that would be filled via Extended Choise Plugin from downloaded files during job1.
And this job2 should wait for user to check/edit default values of these parameters.
And after setting all parameters user can press Build button to start building.
I don't need to auto-run job2 because I need user to see all the parameters from job1.
Is it possible in Jenkins?
You can create a pipeline and in the steps you can ask user for user input to accept or decline for the second job. This way, you can also be notified via an email when the first job completes.
Just refer to the input in the pipeline syntax options.

Build promotion using jenkins upon servicenow change request approval

Build promotion using jenkins upon servicenow change request approval
I need to promote my build to production environment only when my change request# "CHXXXX" has approved? How to achieve this using Jenkins/Servicenow integration?
Please guide me. Thanks in advance.
Typically this is handled by using a "run script" activity in ServiceNow's change workflow.
In your case, you'd have to do the following:
Set up your Jenkins Web service in ServiceNow (REST Web Service Tutorial)
Capture somewhere the Jenkins Pipeline to run (recommendation: on the Configuration Item)
Add the "run script" activity to your Change Management approval workflow in ServiceNow to call the Jenkins API after approval has been granted. You could even introduce a timer to wait until the "planned start" time.
Make sure you capture the Jenkins result / output in your Change ticket for reference.

Build Jenkins Job based on voting result

I have a scenario where on commit to repository branch let say UAT triggers a jenkins job or send email to multiple users. So when all of them click button in email or link Then is It should trigger the jenkins job build.
Can it be done if So then how. I tried to search but could not find a solution.
You could use a Promoted Builds Plugin
Your job could includes an email notification to the person/group responsible for approval. The email contains a link for promotion and an optional comment for approval notes:
Once approved, the next job will run.
I suggest you, using it with a pipeline strategy.
Sources :
https://blogs.perficient.com/2017/06/14/jenkins-delivery-pipeline-and-build-promotion-2/
https://www.cloudbees.com/blog/another-look-jenkins-promoted-builds-plugin
https://www.cloudbees.com/blog/continuous-integration-mobile-apps-jenkins-promoted-builds-qa-process-and-beta-distribution

Resources