Jenkins Email notification for multiple builds - jenkins

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?

Related

How to combine multiple build started Jenkins messages into one email

I am using Jenkins, Gerrit and repo for my project. Often times I make code changes that span across git repositories (all managed through repo). When I submit a CL it triggers multiple Jenkins jobs (pre-submits, cross reference checks, linters...) which sends flurry of build started emails and finally one email with +/-verified status. Wondering if it is possible to combine all the build started emails into one (just like the final verified status email)
I would suggest you to use Pipeline where only one job will be triggered as part of Gerrit trigger and the Pipeline will take care of calling all other jobs and update the Gerrit with the final message.

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

How to use parameter to controller job post build action in Jenkins

I am creating a free style jenkins job and use some post build actions such as: deploy to dropbox, deploy to s3 etc. I want to build two boolean parameters for this job to control whether deploy build results to drop box or s3. For example, if user trigger this job but he doesn't select the s3 parameter, I don't want to trigger the s3 post action. How can I achieve this in Jenkins? I didn't find there is any configurations for that.
You can achieve your requirement using Flexible Publish Plugin.
You need to install the above plugin in your Jenkins.
Then create a freestyle job that will control your choices, that is whether you want to build only Deploy to S3 in the post build or only want to build Deploy to Dropbox in the post build or you want to trigger both the build at once.
In this job create two choice parameters, DEPLOY_TO_S3 and DEPLOY_TO_DROPBOX both with choices YES and NO.
4.Then in the Post-build Actions section choose the Flexible Publish Plugin and do the following configurations and save the job.
Now build your job with parameters and select YES to trigger the down-steam jobs and No to not to trigger the down-stream jobs.
And you are done :)

Is there a way to inform users about a change in Stash repository?

I would like to know if it is possible to send an e-mail notification to certain users when there is a modification to a particular directory within a repository in Stash. I know it is possible to write a shell script within Jenkins project to do this and then inform through e-mail but I would like to know if there is a native option within Jenkins configuration to this action.
This is possible within BitBucket Server itself as of May 7, 2013:
Repository subscriptions
[...] At times, you may want to receive emails on specific types of messages you care most about including:
...
Commits – when a new commit is added or a comment is left
...
See also Manage Inbox and email notifications.
You can use Poll SCM under Build Triggers section.
Define a job that uses GIT plugin, specify a workspace and machine so it'll always be synced with the latest, and poll every 2 minutes. if there is a change in the repository the job will be triggered. Add a post build action to send emails using the built in email notification or using Email-ext plugin.
Don't forget to edit the SMTP information under Manage Jenkins->Configure.
You can check Here for more information about Jenkins Polling.

To get build status through environment variable

I am using jenkins for continous integration.
For my build purpose, i triggering email using Ant task. I am not able to find an environment variable to pass ant for sending email build status(success/failure/stable).
i want to know how can i get environment variable for build status?..if not available, what is the alternative option for build status?
Thanks in Advance
varghese
Why use ANT to send emails from Jenkins when you have two great plugins that does just that?
The default mail notification is quite good, and if you would like to have more control
I suggest using the Email-ext plugin which is very comprehensive.
If still wish to use ANT to sent your mail-notifications including the status
you will have to break your process into two steps,
where the first part runs the build and the second one runs the ANT script to report the status.
In this case, you will need to trigger the second job from the first job via the Parameterized Build plugin -
see my answer here:
trigger other configuration and send current build status with Jenkins
The build status is not set until the job has finished running, so there is no easy way to push build status to a process triggered within the build itself. You could pull build status via the API, but this would have to be an externally triggered process due to the constraint mentioned above. Any reason you aren't using the built in email support or one of the excellent email extension plugins such as this one?

Resources