$BUILD_USER not expanded in Jenkins email notification - email

We use Email Notification plugin as the last build step. When the build is started manually in Jenkins, the $BUILD_USER will expanded properly and show the user name who starts the build. But when the build is triggered automatically by a new commit in GitHub, it shows like this? How can I fix this?
Build Status : Fixed
Build Cause : MANUALTRIGGER
Build user : $BUILD_USER
Build User ID: $BUILD_USER_ID
Build Number : 57
Build Id : 57

The variable wasn't there by default, it requires a new plugin:
https://wiki.jenkins-ci.org/display/JENKINS/Build+User+Vars+Plugin

Related

Jenkins not send any build status to Github

I know there were a lot of conversations to this topic but any of those was helpful to me. So what I'm doing is configuring Jenkins CI to work properly with Github.
We want next:
When someone creates new PR or add commit to existing PR, Github
triggers Jenkins build.
During build is processing we want to see status - pending
Merge button should be disabled till build is completed
After build is completed, we want to see what is the status of that build - successful or failed
Right now, only step 1 works correctly but we can't figure out what is the problem with Jenkins requests to Github!
Also in console output I see error:
ERROR: Build step failed with exception java.lang.IllegalStateException: Can't get remote GH repo for project1 build and don't know what is the problem.
Any help would be really appreciated !
Regards
If you are using GitHub Pull Request Builder , go to trigger setup -> Update commit status during build

Github multiple status checks for pull request

I have a teamcity project running a build against github repo. On completion of the build, it uses a build feature of teamcity named "Report Change Status to Github" which reports the build status using - https://api.github.com
Now I would like to have another teamcity project run a build against the same github repo and report the build status to github.
How do I make github display the 2 status checks differently? Despite the 2 builds reporting status to github, github just displays "1 pending check" or "1 status check completed successfully"
Edit: I didn't realize you already have the plug in installed, but I am going to leave the steps for other users. I think you need separate build configurations and to make sure you customize the context setting.
I was playing with this today and you can't use JetBrains "Commit Status Reporter" to do this. You can use this plugin though: https://github.com/jonnyzzz/TeamCity.GitHub
It wasn't straightforward to install--
Go here (choose Log in as guest): https://teamcity.jetbrains.com/viewType.html?buildTypeId=bt398 and
Click the "View" link in the "Artifacts" column in the latest successful build.
Then you click teamcity.github.zip and it will download a zip file
Then you upload that zip to TeamCity in the plugins section
Once you do that, go to Build Features and click "Add Build Feature" and select "Report change status to GitHub".
Then fill the form out with something like this (Note: You will need this for each build configuration you want reported. I am also running each build on separate agents which might be necessary):
Statuses are created with something called a context:
https://developer.github.com/v3/repos/statuses/#create-a-status
For each commit, the latest status for each context is shown. And for the pull request overall (next to the merge button) the latest per-context statuses of the latest commit in the pull request are shown.
This means that if you want multiple status checks to show up -- those statuses need to be created with different contexts. And that's something defined by the application which is creating statuses, not GitHub. GitHub only displays the statuses.

Fail/pass Jenkins job by email notification

We have an in-company system for creating production builds, and I need to create a Jenkins job to automate those builds.
There is a way to automate the launch of production build. But you can only know the results of the build by an email notification. Furthermore, you can only subscribe to notification using your personal domain credentials, i.e. the same login/pass that you use to log into your computer (and the password changes every month).
So now, Jenkins job is considered "pass" as soon as the build launches, and not when it actually finishes.
I wonder how to make Jenkins pass/fail the job with the given restrictions.
Additionally, I want to avoid:
hardcoding my personal credentials anywhere,
depending on my or anyone else's personal computer being turned on.
Ideas?
I'm not aware of any Jenkins plugin that is capable of receiving e-mails.
If you can manage to store the notifications' content in a file you could use the
Text-finder Plugin in the Post-build Actions of an additional monitor job that runs on a regular basis.
Have a look at Monitoring external jobs, too, whether this is useful for you.
UPDATE:
There is actually a plugin that receives e-mails: the poll-mailbox-trigger-plugin. Install it and do the following:
Create a new Freestyle project named e.g. Build Status Mail Monitor
Build Triggers → [✔] [Poll Mailbox Trigger] - Poll an email inbox
configure as desired
Build → Add build step → Execute Groovy script
◉ Groovy command: add code to change build launcher job's status

Jenkins + Github Pull Request builder display name

For our project we use GitHub. We have TravicCI enabled (as this was required for our project to use). Besides that, we've also got a full instance of Jenkins running with the pull request builder.
Now this all works fine, and in the overview of a pull request this looks like this:
Now as you can see travis is displayed nicely with a name. The Jenkins setup is however shown as 'default'. I'd like to change this to something else, however I can not find anything anywhere (github, jenkins, plugin settings) on how/where to change this. How do I change this?
You can change this in the job.
Your Job > Configure > Build Triggers > Trigger Setup > Commit Status Context
Enter something in this field to override "default".
In the GHPRB ver 1.33.0, the option for changing the name of the check for GitHub PR is within the job configuration:
Your Job > Configure > Build Environment > Set GitHub commit status with custom context and message (Must configure upstream job using GHPRB trigger) > Commit Status Context
I might be late to this answer, but my suggestion is to create another user as a 'bot' account to connect with GitHub from your Jenkins server instead of using your main admin account. This adds another security layer to the connection. I wrote a bit about it here

TFS picks up wrong build to deploy when <Latest> is selected under 'Select an existing Build:'

I am using a build definition that makes use of LabDefaultTemplate.11.xaml for deploying the builds. In the lab process settings i have selected "Latest" under 'Select an existing build' in the Build tab. Ideally it should always pickup the latest available build to deploy BUT instead it is picking some old build which was created few days back. The only difference in the old build and the recent builds is that it passed successfully when it was created whereas the recent builds have partially succeeded.
What might be the problem and possible solution? Quick reply would be appreciated.
Thanks,
-w
Latest in that drop down means it will pick up the Latest successful build. It is working as designed.
If you want to change the logic you'll have to edit the XAML workflow and possibly write a custom activity.