I am running Jenkins within a Docker container on a remote server. In one of my pipelines I am using a Yocto build container to build a image. In this case I have to change the user, because Bitbake does not allow building with root privileges. Unfortunately when I am switching users Jenkins gets stuck during the build stage:
[Pipeline] {
[Pipeline] sh (hide)
process apparently never started in /home/jenkins/workspace/<project>/durable-01a92f6b
(running Jenkins temporarily with Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
[Pipeline] }
My pipeline looks something like this
pipeline {
agent {
docker {
image '<image>/yocto:dunfell'
args '-u jenkins'
}
}
stages {
stage('Build Image') {
steps {
sh label: '', script: '''#!/bin/bash
source /home/jenkins/yocto/setup-env
bitbake core-image-minimal
'''
}
}
}
}
The user jenkins
is available within the Docker container running Jenkins and within the container performing the Yocto build.
Any ideas on resolving this problem? Thanks!
Edit:
I solved this issue by using a workaround. I removed args '-u jenkins'
and the container starts using root. In the script I call the commands which requires no root privileges with
sudo --user=<other-user> /bin/bash -c "<command>"
It works but changing the user beforehand would be preferred.