How do I run Jenkins with a specific working directory and a specific user account?2019 Community Moderator ElectionInit script to run a script as specific userIf I set java bin PATH Dockerfile Jar Command runs but tomcat doesn'tHow to run builds in Docker containers from JenkinsOutput is not getting written in nohup.out while starting the server from jenkinsHow to run a jar together with faketimeHow to run pgpool(or any service) through postgres(any specific) userJenkins in Docker doesn't have access to /dev/vboxnetctl for VirtualBoxJenkins write permission on linuxInvoke UI from pseudo consoleJenkins Docker exec : No such file or Directory
What should be the ideal length of sentences in a blog post for ease of reading?
What the heck is gets(stdin) on site coderbyte?
How do you justify more code being written by following clean code practices?
If the only attacker is removed from combat, is a creature still counted as having attacked this turn?
The Digit Triangles
Did I make a mistake by ccing email to boss to others?
Mimic lecturing on blackboard, facing audience
SOQL query causes internal Salesforce error
How to reduce predictors the right way for a logistic regression model
Pre-Employment Background Check With Consent For Future Checks
Showing mass murder in a kid's book
What is the meaning of "You've never met a graph you didn't like?"
Why is participating in the European Parliamentary elections used as a threat?
How do I fix the group tension caused by my character stealing and possibly killing without provocation?
Why the various definitions of the thin space ,?
Can I cause damage to electrical appliances by unplugging them when they are turned on?
Anime with legendary swords made from talismans and a man who could change them with a shattered body
Has the laser at Magurele, Romania reached a tenth of the Sun's power?
What does "Scientists rise up against statistical significance" mean? (Comment in Nature)
Difference between shutdown options
Can I say "fingers" when referring to toes?
Do I have to know the General Relativity theory to understand the concept of inertial frame?
What's the name of the logical fallacy where a debater extends a statement far beyond the original statement to make it true?
Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?
How do I run Jenkins with a specific working directory and a specific user account?
2019 Community Moderator ElectionInit script to run a script as specific userIf I set java bin PATH Dockerfile Jar Command runs but tomcat doesn'tHow to run builds in Docker containers from JenkinsOutput is not getting written in nohup.out while starting the server from jenkinsHow to run a jar together with faketimeHow to run pgpool(or any service) through postgres(any specific) userJenkins in Docker doesn't have access to /dev/vboxnetctl for VirtualBoxJenkins write permission on linuxInvoke UI from pseudo consoleJenkins Docker exec : No such file or Directory
I am executing below jenkins.war with below command
jenkins -jar jenkins.war
But I want to specify to use below path while executing the war
`/data/jenkins`
and it should run as jenkins
user . Right now it is getting executed as root
user and under /root
directory
How can I achieve that ?
rhel java jenkins
add a comment |
I am executing below jenkins.war with below command
jenkins -jar jenkins.war
But I want to specify to use below path while executing the war
`/data/jenkins`
and it should run as jenkins
user . Right now it is getting executed as root
user and under /root
directory
How can I achieve that ?
rhel java jenkins
Did you create the userjenkins
?
– Panki
yesterday
Also, did you create/data
dir?
– nwildner
yesterday
add a comment |
I am executing below jenkins.war with below command
jenkins -jar jenkins.war
But I want to specify to use below path while executing the war
`/data/jenkins`
and it should run as jenkins
user . Right now it is getting executed as root
user and under /root
directory
How can I achieve that ?
rhel java jenkins
I am executing below jenkins.war with below command
jenkins -jar jenkins.war
But I want to specify to use below path while executing the war
`/data/jenkins`
and it should run as jenkins
user . Right now it is getting executed as root
user and under /root
directory
How can I achieve that ?
rhel java jenkins
rhel java jenkins
edited 20 hours ago
Haxiel
3,35511021
3,35511021
asked yesterday
Zama QuesZama Ques
94282743
94282743
Did you create the userjenkins
?
– Panki
yesterday
Also, did you create/data
dir?
– nwildner
yesterday
add a comment |
Did you create the userjenkins
?
– Panki
yesterday
Also, did you create/data
dir?
– nwildner
yesterday
Did you create the user
jenkins
?– Panki
yesterday
Did you create the user
jenkins
?– Panki
yesterday
Also, did you create
/data
dir?– nwildner
yesterday
Also, did you create
/data
dir?– nwildner
yesterday
add a comment |
2 Answers
2
active
oldest
votes
I used environmental variables as below in script
JENKINS_HOME="/data/jenkins"
JENKINS_WAR="/data/jenkins/jenkins.war"
and passed them to Java with -D option
java -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR
# ps -ef | grep java
root 5 1 0 Mar19 ? 00:05:10 /apps/java/jdk1.8.0_121/bin/java -DJENKINS_HOME=/data/jenkins -jar /data/jenkins/jenkins.war
add a comment |
The Jenkins wiki discusses setting it up as a Unix daemon: Installing Jenkins as a Unix daemon. You have an RHEL tag in the question, and since RHEL 7 makes use of systemd
, you could set up Jenkins to run as a systemd
service. The steps to do this are shown below.
First, you'll need to download the Jenkins WAR file and place it somewhere. I chose the location
/opt/jenkins/jenkins.war
.Next, you'll need to create/prepare the data directory you want to use, which is
/data/jenkins
.You can now create a system user account with the name
jenkins
:useradd -r jenkins
Next, change the ownership of the Jenkins WAR file and data directory to this new user:
chown -R jenkins:jenkins /opt/jenkins/
chown -R jenkins:jenkins /data/jenkins/Next, define the
systemd
service by creating a new unit file:vi /etc/systemd/system/jenkins.service
[Unit]
Description=Jenkins Daemon
[Service]
ExecStart=/bin/java -jar /opt/jenkins/jenkins.war
User=jenkins
Environment=JENKINS_HOME=/data/jenkins
[Install]
WantedBy=multi-user.targetMake
systemd
aware of the new unit by reloading it:systemctl daemon-reload
Finally, start Jenkins:
systemctl start jenkins
You should now be able to access Jenkins on port 8080. If firewalld
is active, you'll need to allow the port by running firewall-cmd --add-port=8080/tcp
on the system.
The Jenkins logs can now be seen with journalctl _SYSTEMD_UNIT=jenkins.service
. Running ps -ef | grep jenkins
will show that it's running as the jenkins
user:
jenkins 1749 1 7 11:04 ? 00:00:35 /bin/java -jar /opt/jenkins/jenkins.war
As an added bonus, run systemctl enable jenkins
if you want the Jenkins service to be automatically started on system boot.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f507090%2fhow-do-i-run-jenkins-with-a-specific-working-directory-and-a-specific-user-accou%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I used environmental variables as below in script
JENKINS_HOME="/data/jenkins"
JENKINS_WAR="/data/jenkins/jenkins.war"
and passed them to Java with -D option
java -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR
# ps -ef | grep java
root 5 1 0 Mar19 ? 00:05:10 /apps/java/jdk1.8.0_121/bin/java -DJENKINS_HOME=/data/jenkins -jar /data/jenkins/jenkins.war
add a comment |
I used environmental variables as below in script
JENKINS_HOME="/data/jenkins"
JENKINS_WAR="/data/jenkins/jenkins.war"
and passed them to Java with -D option
java -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR
# ps -ef | grep java
root 5 1 0 Mar19 ? 00:05:10 /apps/java/jdk1.8.0_121/bin/java -DJENKINS_HOME=/data/jenkins -jar /data/jenkins/jenkins.war
add a comment |
I used environmental variables as below in script
JENKINS_HOME="/data/jenkins"
JENKINS_WAR="/data/jenkins/jenkins.war"
and passed them to Java with -D option
java -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR
# ps -ef | grep java
root 5 1 0 Mar19 ? 00:05:10 /apps/java/jdk1.8.0_121/bin/java -DJENKINS_HOME=/data/jenkins -jar /data/jenkins/jenkins.war
I used environmental variables as below in script
JENKINS_HOME="/data/jenkins"
JENKINS_WAR="/data/jenkins/jenkins.war"
and passed them to Java with -D option
java -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR
# ps -ef | grep java
root 5 1 0 Mar19 ? 00:05:10 /apps/java/jdk1.8.0_121/bin/java -DJENKINS_HOME=/data/jenkins -jar /data/jenkins/jenkins.war
answered 22 hours ago
Zama QuesZama Ques
94282743
94282743
add a comment |
add a comment |
The Jenkins wiki discusses setting it up as a Unix daemon: Installing Jenkins as a Unix daemon. You have an RHEL tag in the question, and since RHEL 7 makes use of systemd
, you could set up Jenkins to run as a systemd
service. The steps to do this are shown below.
First, you'll need to download the Jenkins WAR file and place it somewhere. I chose the location
/opt/jenkins/jenkins.war
.Next, you'll need to create/prepare the data directory you want to use, which is
/data/jenkins
.You can now create a system user account with the name
jenkins
:useradd -r jenkins
Next, change the ownership of the Jenkins WAR file and data directory to this new user:
chown -R jenkins:jenkins /opt/jenkins/
chown -R jenkins:jenkins /data/jenkins/Next, define the
systemd
service by creating a new unit file:vi /etc/systemd/system/jenkins.service
[Unit]
Description=Jenkins Daemon
[Service]
ExecStart=/bin/java -jar /opt/jenkins/jenkins.war
User=jenkins
Environment=JENKINS_HOME=/data/jenkins
[Install]
WantedBy=multi-user.targetMake
systemd
aware of the new unit by reloading it:systemctl daemon-reload
Finally, start Jenkins:
systemctl start jenkins
You should now be able to access Jenkins on port 8080. If firewalld
is active, you'll need to allow the port by running firewall-cmd --add-port=8080/tcp
on the system.
The Jenkins logs can now be seen with journalctl _SYSTEMD_UNIT=jenkins.service
. Running ps -ef | grep jenkins
will show that it's running as the jenkins
user:
jenkins 1749 1 7 11:04 ? 00:00:35 /bin/java -jar /opt/jenkins/jenkins.war
As an added bonus, run systemctl enable jenkins
if you want the Jenkins service to be automatically started on system boot.
add a comment |
The Jenkins wiki discusses setting it up as a Unix daemon: Installing Jenkins as a Unix daemon. You have an RHEL tag in the question, and since RHEL 7 makes use of systemd
, you could set up Jenkins to run as a systemd
service. The steps to do this are shown below.
First, you'll need to download the Jenkins WAR file and place it somewhere. I chose the location
/opt/jenkins/jenkins.war
.Next, you'll need to create/prepare the data directory you want to use, which is
/data/jenkins
.You can now create a system user account with the name
jenkins
:useradd -r jenkins
Next, change the ownership of the Jenkins WAR file and data directory to this new user:
chown -R jenkins:jenkins /opt/jenkins/
chown -R jenkins:jenkins /data/jenkins/Next, define the
systemd
service by creating a new unit file:vi /etc/systemd/system/jenkins.service
[Unit]
Description=Jenkins Daemon
[Service]
ExecStart=/bin/java -jar /opt/jenkins/jenkins.war
User=jenkins
Environment=JENKINS_HOME=/data/jenkins
[Install]
WantedBy=multi-user.targetMake
systemd
aware of the new unit by reloading it:systemctl daemon-reload
Finally, start Jenkins:
systemctl start jenkins
You should now be able to access Jenkins on port 8080. If firewalld
is active, you'll need to allow the port by running firewall-cmd --add-port=8080/tcp
on the system.
The Jenkins logs can now be seen with journalctl _SYSTEMD_UNIT=jenkins.service
. Running ps -ef | grep jenkins
will show that it's running as the jenkins
user:
jenkins 1749 1 7 11:04 ? 00:00:35 /bin/java -jar /opt/jenkins/jenkins.war
As an added bonus, run systemctl enable jenkins
if you want the Jenkins service to be automatically started on system boot.
add a comment |
The Jenkins wiki discusses setting it up as a Unix daemon: Installing Jenkins as a Unix daemon. You have an RHEL tag in the question, and since RHEL 7 makes use of systemd
, you could set up Jenkins to run as a systemd
service. The steps to do this are shown below.
First, you'll need to download the Jenkins WAR file and place it somewhere. I chose the location
/opt/jenkins/jenkins.war
.Next, you'll need to create/prepare the data directory you want to use, which is
/data/jenkins
.You can now create a system user account with the name
jenkins
:useradd -r jenkins
Next, change the ownership of the Jenkins WAR file and data directory to this new user:
chown -R jenkins:jenkins /opt/jenkins/
chown -R jenkins:jenkins /data/jenkins/Next, define the
systemd
service by creating a new unit file:vi /etc/systemd/system/jenkins.service
[Unit]
Description=Jenkins Daemon
[Service]
ExecStart=/bin/java -jar /opt/jenkins/jenkins.war
User=jenkins
Environment=JENKINS_HOME=/data/jenkins
[Install]
WantedBy=multi-user.targetMake
systemd
aware of the new unit by reloading it:systemctl daemon-reload
Finally, start Jenkins:
systemctl start jenkins
You should now be able to access Jenkins on port 8080. If firewalld
is active, you'll need to allow the port by running firewall-cmd --add-port=8080/tcp
on the system.
The Jenkins logs can now be seen with journalctl _SYSTEMD_UNIT=jenkins.service
. Running ps -ef | grep jenkins
will show that it's running as the jenkins
user:
jenkins 1749 1 7 11:04 ? 00:00:35 /bin/java -jar /opt/jenkins/jenkins.war
As an added bonus, run systemctl enable jenkins
if you want the Jenkins service to be automatically started on system boot.
The Jenkins wiki discusses setting it up as a Unix daemon: Installing Jenkins as a Unix daemon. You have an RHEL tag in the question, and since RHEL 7 makes use of systemd
, you could set up Jenkins to run as a systemd
service. The steps to do this are shown below.
First, you'll need to download the Jenkins WAR file and place it somewhere. I chose the location
/opt/jenkins/jenkins.war
.Next, you'll need to create/prepare the data directory you want to use, which is
/data/jenkins
.You can now create a system user account with the name
jenkins
:useradd -r jenkins
Next, change the ownership of the Jenkins WAR file and data directory to this new user:
chown -R jenkins:jenkins /opt/jenkins/
chown -R jenkins:jenkins /data/jenkins/Next, define the
systemd
service by creating a new unit file:vi /etc/systemd/system/jenkins.service
[Unit]
Description=Jenkins Daemon
[Service]
ExecStart=/bin/java -jar /opt/jenkins/jenkins.war
User=jenkins
Environment=JENKINS_HOME=/data/jenkins
[Install]
WantedBy=multi-user.targetMake
systemd
aware of the new unit by reloading it:systemctl daemon-reload
Finally, start Jenkins:
systemctl start jenkins
You should now be able to access Jenkins on port 8080. If firewalld
is active, you'll need to allow the port by running firewall-cmd --add-port=8080/tcp
on the system.
The Jenkins logs can now be seen with journalctl _SYSTEMD_UNIT=jenkins.service
. Running ps -ef | grep jenkins
will show that it's running as the jenkins
user:
jenkins 1749 1 7 11:04 ? 00:00:35 /bin/java -jar /opt/jenkins/jenkins.war
As an added bonus, run systemctl enable jenkins
if you want the Jenkins service to be automatically started on system boot.
answered 20 hours ago
HaxielHaxiel
3,35511021
3,35511021
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f507090%2fhow-do-i-run-jenkins-with-a-specific-working-directory-and-a-specific-user-accou%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you create the user
jenkins
?– Panki
yesterday
Also, did you create
/data
dir?– nwildner
yesterday