console run as jenkins i can mkdir, but when i run mkdir in build task, i get permission denied

9,275 views
Skip to first unread message

KimSia Sim

unread,
Mar 8, 2013, 4:51:04 AM3/8/13
to jenkins...@googlegroups.com
I have this command

mkdir /var/virtual/folder

I can execute this when I ssh into my server as `jenkins`

/var/virtual belongs to www-data, but not an issue because I made /var/virtual 775 and `jenkins` is a member of `www-data` group


However, when I run the exact same command in my web interface Jenkins system as a build task, I get a permission denied.

I am running  Jenkins ver. 1.504 Please advise.

JonathanRRogers

unread,
Mar 8, 2013, 11:46:39 AM3/8/13
to jenkins...@googlegroups.com


On Friday, March 8, 2013 4:51:04 AM UTC-5, KimSia Sim wrote:
I have this command

mkdir /var/virtual/folder

I can execute this when I ssh into my server as `jenkins`

/var/virtual belongs to www-data, but not an issue because I made /var/virtual 775 and `jenkins` is a member of `www-data` group


However, when I run the exact same command in my web interface Jenkins system as a build task, I get a permission denied.

 It might be helpful to put commands in the script run from Jenkins to print as much about the environment as possible, including logged in account (whoami) and current group membership (groups) and current working directory. Prefix the command which fails with "echo" to make sure it is exactly the same as what you type interactively.

KimSia Sim

unread,
Mar 9, 2013, 1:21:33 AM3/9/13
to jenkins...@googlegroups.com
Under build step execute shell command, I only have the following

echo "running whoami" & whoami
echo "running groups" & groups
echo $PWD
mkdir /var/virtual/stage.xxx.com/test1

These are my results.
+ whoami
jenkins
+ echo running whoami
running whoami
+ groups
nogroup
+ echo running groups
running groups
+ echo /var/lib/jenkins/workspace/LTE develop
/var/lib/jenkins/workspace/LTE develop
+ mkdir /var/virtual/stage.xxx.com/test1
mkdir: cannot create directory `/var/virtual/stage.xxx.com/test1': Permission denied
Build step 'Execute shell' marked build as failure
Finished: FAILURE

What should I do next?

KimSia Sim

unread,
Mar 9, 2013, 1:32:06 AM3/9/13
to jenkins...@googlegroups.com
I had a relevation when I logged in to my Console as jenkins and I run groups


I saw

nogroup sudo www-data

but in the window shell command of the build step, I only had

nogroup

I suspect this is the reason.

How do I overcome this problem? I have already tried restarting my jenkins.

It is still running as nogroup

Jonathan Rogers

unread,
Mar 9, 2013, 1:35:17 AM3/9/13
to jenkins...@googlegroups.com
KimSia Sim wrote:
> Under build step execute shell command, I only have the following
> echo "running whoami" & whoami
> echo "running groups" & groups
> echo $PWD
> mkdir /var/virtual/stage.xxx.com/test1
>
> These are my results.
> + whoami
> jenkins
> + echo running whoami
> running whoami
> + groups
> nogroup
> + echo running groups
> running groups
> + echo /var/lib/jenkins/workspace/LTE develop
> /var/lib/jenkins/workspace/LTE develop
> + mkdir /var/virtual/stage.xxx.com/test1
> mkdir: cannot create directory `/var/virtual/stage.xxx.com/test1': Permission denied
> Build step 'Execute shell' marked build as failure
> Finished: FAILURE
> What should I do next?

As you can see from your above output, the Jenkins process is running as
a member of the "nogroup" group, not "www-data". This probably means
that user "jenkins" is not listed as member of "www-data" in /etc/group.
Alternatively, the script which starts Jenkins or Jenkins itself could
be explicitly changing the group membership. You need to determine why
Jenkins is not running with the group membership you expect. Keep in
mind that group membership is determined at process start time so you
have to restart Jenkins after changing /etc/group to see any effects.

BTW, in a shell script the "&" character means to run the preceeding
command in the background, which probably not what you intended as the
reason that the output order is odd. Use ';' to separate two commands
but execute them sequentially.

>
> On Saturday, March 9, 2013 12:46:39 AM UTC+8, JonathanRRogers wrote:
>
>
>
> On Friday, March 8, 2013 4:51:04 AM UTC-5, KimSia Sim wrote:
>
> I have this command
>
> mkdir /var/virtual/folder
>
> I can execute this when I ssh into my server as `jenkins`
>
> /var/virtual belongs to www-data, but not an issue because I
> made /var/virtual 775 and `jenkins` is a member of `www-data`
> group
>
>
> However, when I run the exact same command in my web interface
> Jenkins system as a build task, I get a permission denied.
>
> It might be helpful to put commands in the script run from
> Jenkins to print as much about the environment as possible,
> including logged in account (whoami) and current group membership
> (groups) and current working directory. Prefix the command which
> fails with "echo" to make sure it is exactly the same as what you
> type interactively.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/jenkinsci-users/GXSmF6RfluM/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> jenkinsci-use...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


--
Jonathan Rogers

KimSia Sim

unread,
Mar 9, 2013, 1:45:19 AM3/9/13
to jenkins...@googlegroups.com
Thank you for your advice Jonathan!

I have solved the problem by restarting the Jenkins service.

I had to run the following command in my console.

sudo service jenkins restart

This restart works better than the web gui restart sequence.

For reasons unknown to me.

Jonathan Rogers

unread,
Mar 9, 2013, 5:47:25 AM3/9/13
to jenkins...@googlegroups.com
KimSia Sim wrote:
> Thank you for your advice Jonathan!
>
> I have solved the problem by restarting the Jenkins service.
>
> I had to run the following command in my console.
>
> sudo service jenkins restart
>
> This restart works better than the web gui restart sequence.
>
> For reasons unknown to me.

Group membership is only set at the beginning of a session or by using
an explicit command like newgrp. If you edited /etc/group while Jenkins
was running, then told Jenkins to restart itself, it would not have
picked up the changes. An initscript invoked by the service command does
start the service in a new session.

>
> On Saturday, March 9, 2013 2:35:17 PM UTC+8, JonathanRRogers wrote:
>
> KimSia Sim wrote:
> > Under build step execute shell command, I only have the following
> > echo "running whoami" & whoami
> > echo "running groups" & groups
> > echo $PWD
> > mkdir /var/virtual/stage.xxx.com/test1 <http://stage.xxx.com/test1>
> >
> > These are my results.
> > + whoami
> > jenkins
> > + echo running whoami
> > running whoami
> > + groups
> > nogroup
> > + echo running groups
> > running groups
> > + echo /var/lib/jenkins/workspace/LTE develop
> > /var/lib/jenkins/workspace/LTE develop
> > + mkdir /var/virtual/stage.xxx.com/test1
> <http://stage.xxx.com/test1>
> > mkdir: cannot create directory `/var/virtual/stage.xxx.com/test1
> <http://stage.xxx.com/test1>': Permission denied
> <https://groups.google.com/d/topic/jenkinsci-users/GXSmF6RfluM/unsubscribe?hl=en>.
>
> > To unsubscribe from this group and all its topics, send an email to
> > jenkinsci-use...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
> >
> >
>
>
> --
> Jonathan Rogers

koppula chiranjeevi

unread,
Apr 26, 2016, 7:14:19 AM4/26/16
to Jenkins Users
I am getting the following error message with Jenkins 2.0 build . can you help me :

java.io.IOException: Failed to mkdirs: /var/jenkins/workspace/clinfo/label/ROCm-Fiji1
	at hudson.FilePath.mkdirs(FilePath.java:1163)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1267)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
	at hudson.model.Run.execute(Run.java:1738)
	at hudson.matrix.MatrixRun.run(MatrixRun.java:146)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:410)
Finished: FAILURE
Reply all
Reply to author
Forward
0 new messages