由于“sudo:未知 uid 1001:你是谁?”导致 Jenkins 管道失败
我正在尝试使用 Jenkins 和 Django 部署我的 Django 应用程序。 我发现管道在 UID 1001 的 sudo 命令上失败。但是,我已在 docker 映像上显式创建了一个具有 UID 的用户。我对 Docker 和 Jenkins 还很幼稚。您能否帮助确定可能出现问题的地方?管道步骤 用户 Jenkins 上的输出
这是 jenkins 脚本:
void setBuildStatus(String message, String state) {
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/***"],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
]);
}
node('linux-builder')
{
def tmpDirName = UUID.randomUUID().toString()
stage('Linux:Workspace cleanup')
{
step([$class: 'WsCleanup'])
}
stage('Linux:Repo clone')
{
// Clone abc repository
checkout([$class: 'GitSCM',
branches: [[name: "master"]],
extensions: [[$class: 'GitLFSPull']],
userRemoteConfigs: [[credentialsId: '***',
url: '[email protected]:***']]
])
}
setBuildStatus("Build pending", "PENDING")
try
{
stage('Run tests')
{
sh "cp /home/jenkins/.ansible-vault-key.txt ansible/.ansible-vault-key.txt"
docker.image('***:2.2').inside('--entrypoint=')
{
sh """export CI=jenkins
sudo service postgresql start
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
sudo script/bootstrap
export CI=jenkins
script/deploy master"""
}
}
setBuildStatus("Build succeeded", "SUCCESS");
}
catch(e)
{
setBuildStatus("Build failed", "FAILURE");
}
}
该脚本在 postgresql 服务启动命令上尤其失败。
I am trying to deploy my Django application using Jenkins and Django.
I see that pipelines fails on sudo
command for UID 1001. However, I have explicitly created a user with UID on docker image. I am quite naive in Docker and Jenkins. Could you help to identify what could have possibly gone wrong?Pipeline steps Users Output on Jenkins
Here is the jenkins script:
void setBuildStatus(String message, String state) {
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/***"],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
]);
}
node('linux-builder')
{
def tmpDirName = UUID.randomUUID().toString()
stage('Linux:Workspace cleanup')
{
step([$class: 'WsCleanup'])
}
stage('Linux:Repo clone')
{
// Clone abc repository
checkout([$class: 'GitSCM',
branches: [[name: "master"]],
extensions: [[$class: 'GitLFSPull']],
userRemoteConfigs: [[credentialsId: '***',
url: '[email protected]:***']]
])
}
setBuildStatus("Build pending", "PENDING")
try
{
stage('Run tests')
{
sh "cp /home/jenkins/.ansible-vault-key.txt ansible/.ansible-vault-key.txt"
docker.image('***:2.2').inside('--entrypoint=')
{
sh """export CI=jenkins
sudo service postgresql start
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
sudo script/bootstrap
export CI=jenkins
script/deploy master"""
}
}
setBuildStatus("Build succeeded", "SUCCESS");
}
catch(e)
{
setBuildStatus("Build failed", "FAILURE");
}
}
The script particularly fails on the postgresql service start command.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论