how to find which user executed the job - jenkins

We have LDAP login setup for user login and execute jobs. how to monitor users activities for the jobs that a particular user executed.
So far the only way I have seen is to go each job's console output and look for "Started by user". Is there any other way I can list all users with the jobs they executed?
Thanks

you can use this plugin https://wiki.jenkins-ci.org/display/JENKINS/Build+User+Vars+Plugin,
and adopt your build configuration.

Related

Updating user emails in Jenkins

We have a Jenkins setup in which jobs are pipelines that call the email-ext plugin to notify users.
After the jobs have been setup, all users have changed emails, going from user#company1.com to user#company2.com.
Jenkins still sends emails to the former adresses.
I can't find a way to update the email adresses. Is there a way to do this ?
Users are authenticated through the Active Directory plugin.
You just have to update to address while sending. Check this on how to do it. Since you might need to update the config on multiple jobs you might need to write a script to achieve that. This thread explains it

Is there a way in Jenkins to create a manual approval for a job to be approved by multiple approvers?

I have a promotion Job A which on successful build triggers email to certain recipients with Jenkins console link and build#. When the user clicks on the link from the email, he will login through his user id and clicks on approve, upon which Job B in the pipeline triggers. Now I want to achieve this for multiple approvers, meaning if Job A sent email to 3 users, Job B should not be triggered until all approvers approve. Seems like their is no option in promoted build plugin for the same. Any ideas, suggestions would be helpful.
May be this plugin can help you with the approvals.
Build Pipeline
This plugin provides a Build Pipeline View of upstream and downstream connected jobs that typically form a build pipeline. In addition, it offers the ability to define manual triggers for jobs that require intervention prior to execution, e.g. an approval process outside of Jenkins

Jenkins Remote Trigger User Name

I am developing a Dashboard on top of Jenkins. The Dashboard would list all the jobs available and would also have a trigger button to initiate a build which shoots a post request using the secret token. The problem is every build would have the same cause which says "Started by remote host 19.XX.XX.XX". Since the dashboard needs to display the user name triggering the job as the person who logged, is there a way we can pass the a username as well in the jenkins remote trigger url like below so that jenkins would capture the cause as the user name.
https://jenkinsurl:port/job/testLDAP/build?token=DDJjk$###*bB&userName=abc
There is no parameter that you can use for this. A workaround that I've used is adding &cause=This+was+started+by+abc which results in
Started by remote host 192.168.x.x with note: This was started by abc
Perhaps this might help you.

jenkins hide certain build parameters from general users

I have a project based security enabled for my jobs. And based on user being admin / non-admin would like to show / hide certain build parameters.
Can anyone suggest an approach to tackle this requirements or are there any plugins for this?
Thanks!! Appreciate your help on this.
I don't think there is such a feature directly, but there is a workaround.
Configure "non-admin" job with only the parameters that non-admins should see.
Give that job security so that non-admins can build it.
Configure second "admin" job
Give that second job security so that only admins can build it.
In the Job Configuration of the second "admin" job, you need to:
Define all parameters (admin and non-admin)
Use Parameterized Trigger plugin ("Trigger/call builds on other projects" build action) to trigger "non-admin" job
Configure Add Parameters -> Current build parameters
That's it.
In the Job Configuration of the first "non-admin" job, you need to:
Define just non-admin parameters, making sure their names are exactly same as overlapping parameters from "admin" job
Configure the rest of the job as you normally would.
All parameters, even those that are passed from the triggering "admin" job are available as environment variables (even if they are not explicitly defined in "non-admin" job)

How to block some Jobs for some user level in Jenkins?

I want a block some jobs for a user level for example I have 3 jobs:
Job1 (All the register user can execute this).
Job2 (Only some user can execute this)
Job3 (All the register user can execute this).
Set the Global Security (http://<your_server>/configureSecurity/?) to the configuration that matches most jobs (enable Job Build) and then enable Project-based security for the other jobs (via the jon configuration) and set up as required by disabling Job Build.
Enter the user name in User/group to add: and then configure as required. In this case I've limited control to two users
You need to use Project-based Matrix Authorization Strategy to achieve this. Hudson/Jenkin >> Manage Hudson >> Configre Security >> Authorization, and select Project-based Matrix Authorization Strategy. Now in the configuration page of each job you will have an option Enable job-based security. You can give access permissions for the users here.
This works for me : Role Strategy Plugin
But you need understand it and its official documentation is poor, so go to :
https://stackoverflow.com/a/38516162/3957754
The below link provides the clear guideline to grant/restrict the access to Jenkins Jobs.
http://www.kblearningacademy.com/configure-role-strategy-plugin-in-jenkins/
Its very useful & am able to do the same.

Resources