Get the user name who triggered a build in bamboo - jenkins

I am trying to create a task which invokes jenkins job to deploy the environment with username that should be passed from bamboo.
I didn't get any bamboo variable that contains the name of the user that triggered a build. Found one that has the username of the person who created a release in Jira, but this isn't what I want.
For manual trigger, used ${bamboo.ManualBuildTriggerReason.userName}, that gives the name of the person who triggered a build. But need the user name when triggered plan automatically from JIRA.
Is there a way to get the user name?

Related

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

Is it possible to get the name of the user who triggered another Jenkins job through a static link?

I have a Jenkins job, ABC. The job runs every 24 hours as defined in the crontab. A build description is set after each successful build. The description is basically a link that triggers another job, XYZ.
Is it somehow possible to know which user clicked the link and triggered the job XYZ?
Cheers!
Yes, you just need to click in the status option of your job :

Deploying jenkins jobs for dynamically created gitlab repos

Setup:
1 Jenkins server and 1 gitlab server that I own
Expected usage:
- We provision repositories for users on gitlab using some scripts when a user signs up with our portal.
- As soon as these users submit some code in the repository, we have to run some junit tests on them and email the users with a the test results in a clean way where they can see the passed and failed results with appropriate links which they can click on to get details of the tests.
Requirements for. jenkins:
1. Ability to send html junit test results with clickable test result links
2. Based on whether the junit test fails or passes, call two different python scripts.
Questions:
1. What is the best way to go about 1 and 2 requirements
2. Should I create a job template and create a job per dynamically created repo or can I use same job to run tests on multiple repos
References :
These were the links we referred.But as a newbie to jenkins couldn't come up with clear solutions.
1.https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin#Email-extplugin-Jellycontent
2.https://gist.github.com/nightspotlight/7cfa6af7c7989857f336f742cdcb443b
3.https://learn2automate.blog/2017/05/19/how-to-set-jenkins-job-status-based-on-test-case-pass/
Send some links in your mail using jenkins is simple
Install https://wiki.jenkins.io/display/JENKINS/Email-ext+plugin
Install https://wiki.jenkins.io/display/JENKINS/Build+With+Parameters+Plugin in order to expose a job as link with params
Create some job in jenkins and in the post-build section add editable email notification
[![enter image description here][1]][1]
in In Default Content of editable email notification you must write the email body that will be sent to your users. If your requirement is send a link to allow user to open another jenkins page, you could write the following :
In order to execute python scripts click in this link
http://your-jenkins.com/job/my-job-python/parambuild/?param1=test1&param2=etc
Your mail provider will render this text as html.
Finally you need to create some job with name my-job-python with parameters param1, param2 or whatever. This job will execute your python scripts when user clicks on email links sent by jenkins.

TFSbuild variables, username and schedule time

Is there a way in a build step to retrieve the username of the person who triggers a build in TFS2018 using the build variables?
Also is it possible to get the time the build was triggered?
There are BUILD_QUEUEDBY and BUILD_REQUESTEDFOR pre-defined variables that will help you identify the user started the build. There are also BUILD_QUEUEDBYID and BUILD_REQUESTEDFORID that should return the user id for the user triggered the build (https://learn.microsoft.com/en-us/vsts/build-release/concepts/definitions/build/variables?tabs=batch#identity_values).
As for the time the build started, you could either just define a custom variable and populate it in a build step, or (which is a bit trickier) use REST API to query build details about currently running build, then parse the output, which will give you build start time (https://www.visualstudio.com/en-us/docs/integrate/api/build/builds)

Retrieve console log from a nested job in jenkins

I have a Matrix job (Job A) with that call build sub job (B) using Jenkins Parameterized Trigger plugin.
In the Parent Job (Mtrix) i use Editable Email Notification to trigger each configuration.
I want to get 15 lines from child job (B) build log for each configuration to add it in the email (if the build fails).
How can I do such thing ?
This plugin allows you to configure every aspect of email notifications. You can customize when an email is sent, who should receive it, and what the email says.
here is the link : https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin

Resources