Using Jenkins 2.277.2 (LTS) and Extended E-mail Notification and build user vars plugins I'm trying to send emails before build to notify build-user that job is started and also after success/fail.
Problem is that I need to use ${BUILD_USER_ID} variable and it does not get exposed for Before Build trigger. For any other triggers that I tested (always, failure - any, success) it is exposed correctly, however all of those emails are being sent after the build, and I need to notify build-user that job is started.
Any ideas how to achieve that? Ideally without any more plugins installation, but if there's no way - that's kind of acceptable too.
Thanks.
upd It'd probably be easier for me to illustrate what I meant - here's how it looks https://i.imgur.com/YdG1N9C.png
Related
I occasionally want to get notified when a particular jenkins job that is building finishes. Is there any way to do this?
Scripting it through the API would be fine. I already have the jenkins IRC bot that notifies me of many things, so if I could just dynamically modify the running job build, that would be enough to do what I want -- I'm just having a hard time finding how to accomplish that.
AFAIK, you cannot change a job's config while it's running.
Here is an idea: Use a post-build step to check for an external resource status (like a file containing an action by text) and running an action based on the content of the file.
The external file can be modified while the build is running, so when the post-build is executed, it will follow the logic defined based on the content of the file.
I hope this helps.
You can use email notifier, It will send you an email
https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
We're using Jenkins and Slack.
I'm trying to setup a slack notification about a build, and I would like the notifucation to include more information - so I resort to the custom message.
I found about $GIT_BRANCH and $BUILD_NUMBER and $JOB_NAME and other interesting guys, and put them to use.
But I lack a way to mention the cause that triggered the build - be it a polling on the scm, or a user that pressed build now.
The later is of extreme importance - especially in jobs that deploy to a target environment...
Can anybody recommend me a way to detect the triggering cause and add it to the custom message?
BTW - I'd want this information not only for slack notification.
I'd like to add this information to a signature file that we add to every artifact (as well as other things)
Use the Build User Vars Plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Build+User+Vars+Plugin
You will have the variables:
BUILD_USER – full name of user started build,
BUILD_USER_FIRST_NAME – first name of user started build,
BUILD_USER_LAST_NAME – last name of user started build,
BUILD_USER_ID – id of user started build.
*If you want to get it from other job you can use the below URL:
http://[jenkins-server]/job/[job-name]/[build-number]/api/xml?xpath=(//action/cause/shortDescription)
It will directly return the line:
< shortDescription>Started by user foobar< /shortDescription>
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.
Is there a way to get the hudson job initiated user name.
Is it possible to get using script shell, py etc.
Lets assume I have the build # which was initiated. I know how to get the latest build info using api but would like to get a user details for a specific job.
Do you think, this will work for hudson? :)
https://wiki.jenkins-ci.org/display/JENKINS/Build+User+Vars+Plugin
Thanks in advance
That plugin will not work with Hudson, unless you download a very old version of the plugin. I'm not sure how many people are still using Hudson and haven't upgraded to Jenkins.
Anyway, when a user manually triggers a build, this is called a "user cause"; there are other types of cause, e.g. SCM trigger.
You can use the JSON or XML API to get the causes for a build, for example:
https://ci.jenkins-ci.org/job/remoting/lastSuccessfulBuild/api/xml?xpath=//action/cause/userId
In this case, this returns the username that caused the build to run.
Though note that there may be multiple causes for a build, and potentially other cause types that use the userId field.
This works in Jenkins, but it should also work in Hudson, but I haven't tested it.
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?