Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get username logged in Jenkins from Jenkins Workflow (Pipeline) Plugin

I am using the Pipeline plugin in Jenkins by Clouldbees (the name was Workflow plugin before), I am trying to get the user name in the Groovy script but I am not able to achieve it.

stage 'checkout svn'  node('master') {       // Get the user name logged in Jenkins } 
like image 655
Daniel Hernández Avatar asked Mar 09 '16 21:03

Daniel Hernández


People also ask

How do you check who triggered the build in Jenkins?

Within CloudBees Jenkins the cause of any Build for a particular job should be listed in the UI by navigating to said job and selecting the Build number in question from the left hand column. For example the UI on the build page will show: Branch indexing , Started by user $USER .

What is checkout SCM in Jenkins?

1. The checkout step will checkout code from source control; scm is a special variable which instructs the checkout step to clone the specific revision which triggered this Pipeline run.

How can I see pipeline in Jenkins?

Step 4) Go to your Jenkins dashboard and create a view by clicking on the “+” button. Select the Build Pipeline View option and click OK. Step 5) Under Pipeline view configuration, locate Pipeline Flow. Under Pipeline flow, select the initial job to run.

How Jenkins knows where Jenkins job will be started?

I have a Jenkins job which does some unit-testing for some code. It can be started in two possible ways: By the scheduler - it polls the Perforce server, and starts the job when it detects a code change. By a user, on demand - it downloads a shelved/stashed code change, and checks whether it breaks the tests.


1 Answers

Did you try installing the Build User Vars plugin? If so, you should be able to run

node {   wrap([$class: 'BuildUser']) {     def user = env.BUILD_USER_ID   } } 

or similar.

like image 147
Jesse Glick Avatar answered Sep 30 '22 18:09

Jesse Glick