Reputation: 1443
I've created a jenkins server, and I am trying to build a .net core 2.0.0 project on the server. I've been able to successfully pull from source control and store source files in the workspace. However, I'm running into an issue with running the dotnet build command. This is what I'm getting.
/usr/share/dotnet/sdk/2.0.0/Microsoft.Common.CurrentVersion.targets(4116,5): error MSB3021: Unable to copy file "obj/Debug/netcoreapp2.0/ubuntu.16.04-x64/Musify.pdb" to "bin/Debug/netcoreapp2.0/ubuntu.16.04-x64/Musify.pdb". Access to the path is denied. [/var/lib/jenkins/workspace/Musify/Musify.csproj]
now, I've given read write and execute permissions to every file and directory in /usr/share/dotnet/sdk/2.0.0/, and I've given read write and execute to every file and directory in my workspace (/var/lib/jenkins/workspace/Musify). I also believe my jenkins user is part of the sudo group.
The weird thing I am experiencing, is that I am able to, as root, run dotnet build in my workspace directory (/var/lib/jenkins/workspace/Musify), and the project builds. I cannot however, get the same results under the jenkins user (who should be part of the sudo group). My question is, how can I verify that Jenkins is using the jenkins system user, and that this user has the correct permissions to run this command. I am hosting jenkins on an ubuntu 16.04 x64 server.
Upvotes: 3
Views: 6064
Reputation: 3118
If you want to fix the dotnet build
issue take following actions:
DOTNET_CLI_HOME
environment variable on the docker to a common
path like /tmp
on the container. This path is used by the dotnet
to create necessary files to build the project. Check
Dotnet build permission denied in Docker container running Jenkins-o
or another accessible path to create the artifacts in the desired directory. e.g. dotnet build -o /tmp/dotnet/build/
microsoftisnotthatbad.sln
Re the jenkins user problem, run whoami
in the container. If you get whoami: cannot find name for user ID blahblah
it means the user is not found in the passwd
file. There are 2 answers under Docker Plugin for Jenkins Pipeline - No user exists for uid 1005, if item 1 did not work, try the second:
passwd
to the container. LDAP
on the Jenkins server or the slave server your job is using, the passwd
file of the host will not have the jenkins user. Check the other answer on that post.Upvotes: 2
Reputation: 8172
At the command line on your jenkins host run
ps -ef | grep jenkins
the first column will give you the USERID and it should be, as you say, jenkins
Then if you can login as jenkins to the host where the jenkins server is running run the following ....
groups
this will list out the groups that jenkins is a part of
Upvotes: 2