Run Jenkins Job as Another User

How to run jenkins's job as a specific user?

Builds always run under the user that runs the node agent process. So your options are

  • Specify a different user for connecting the node, or
  • Switch to a different user during the build (e.g., via sudo in a shell build step). This is more flexible, but plugin related-code (like SCM checkout) will still run under the root account.

Run jenkins job as another user

There is JENKINS_USER variable in etc/default/jenkins file. You could change it to ci_user, then you will need to change the ownership of several folders and reboot the machine.

chown -R ci_user /var/lib/jenkins
chown -R ci_user /var/log/jenkins
chown -R ci_user /var/cache/jenkins

Reference

How to run Jenkins jobs as user other than anonymous?

I found it.

In Manage Jenkins -> Configure Global Security, toward the middle of page there's a section called Access Control For Builds. The Strategy was set to Run as anonymous, I set it to Run as SYSTEM.

Jenkins, how to run a job that needs to log in as another user?

The solution I have chosen so far is to give specific sudo rights to the Jenkins user in order to allow him to use some commands like hive or hdfs.

Run Jenkins jobs on Linux under a User

Have a look at the Started-By Environment Variable plugin.

https://wiki.jenkins-ci.org/display/JENKINS/Started-By+Environment+Variable+Plugin

EDIT:

If you are just asking how to set up Jenkins to run under a different user in Linux it depends on how you installed it. I never set up Jenkins on Linux yet (but I can use google). Have a look at https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins for different setup options. I had a look at Installing Jenkins as a Unix daemon and at step 7 you need to setup a configuration file. Change the last line in that file (RUN_AS_USER=jenkins) to contain the user of your choice.

How to run jenkins as a different user

ISSUE 1:

Started by user anonymous

That does not mean that Jenkins started as an anonymous user.

It just means that the person who started the build was not logged in. If you enable Jenkins security, you can create usernames for people and when they log in, the

"Started by anonymous" 

will change to

"Started by < username >". 

Note: You do not have to enable security in order to run jenkins or to clone correctly.

If you want to enable security and create users, you should see the options at Manage Jenkins > Configure System.


ISSUE 2:

The "can't clone" error is a different issue altogether. It has nothing to do with you logging in to jenkins or enabling security. It just means that Jenkins does not have the credentials to clone from your git SCM.

Check out the Jenkins Git Plugin to see how to set up Jenkins to work with your git repository.

Hope that helps.



Related Topics



Leave a reply



Submit