Jenkins user not in passwd on dynamic jnlp slave in kubernetes

5/10/2019

I am building a system to do c++ cmake builds primarily. I have Jenkins firing the dynamic pods, firing off shell scripts, etc. But, I can't get it to checkout the code. Now, my Jenkinsfile launches a container that the actual compile is supposed to be run in. That "sub" container is tuned to compile C++ code. Now, I have jenkins running scripts and such in that pod, but, when i try

checkout scm

im getting errors saying

ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --force --progress git@gitlab.com:mystuff/hello-world-cmake.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: No user exists for uid 1000080000
fatal: Could not read from remote repository.

my home folder is the standard /home/jenkins and the workspace folder is there, etc, etc. But, when I dump the /etc/passwd file, the jenkins user isn't listed in it.

Whats the appropriate way to add the jenkins user to that file?

-- scphantm
jenkins
jenkins-pipeline
kubernetes

1 Answer

5/11/2019

What image are you using for Jenkins slave? Does it have user jenkins? If it has you need to specify this in your spec for Jenkins slave:

spec:
  securityContext:
    runAsUser: 1000

UPDATE:

You cannot run default Jenkins image in Openshift, because Openshift runs containers as random user. You should run Jenkins from builtin Jenkins template "Jenkins Persistent". If you don't have this template and don't have Jenkins image stream - you can try to use image openshift/jenkins-2-centos7. See details at:

https://github.com/openshift/jenkins/issues/168

https://github.com/openshift/jenkins

-- Vasily Angapov
Source: StackOverflow