【发布时间】:2021-06-09 11:06:09
【问题描述】:
我正在尝试在我的 Ubuntu 服务器上设置 Jenkins。
$ sudo -u otherUser /bin/bash
$ whoami # I expected "otherUser" but show "jenkins"
$ start_build_script.sh # This file will clones multiple remote repository
但是当 git 克隆时,它的进程会失败,因为它使用“jenkins”用户进行克隆。
jenkins@repo.com: Permission denied (publickey).
# The public key (for "otherUser") is already added to repo.com
# I want to clone as otherUser@repo.com
我知道为什么会发生此错误,但遗憾的是我无法将“jenkins”用户添加到存储库站点。所以我必须使用“otherUser”用户。
我只能在我的 ubuntu 服务器中修改文件,但我无法修改远程存储库中的任何内容。
如何在运行构建脚本时将用户更改为其他用户,而不是“jenkins”?
【问题讨论】:
-
没有足够的详细信息,但您可以将控制器/主节点设置为一个用户,将 egannode 设置为另一个用户,并将克隆中的使用凭证设置为另一个用户。为什么要把它全部包装在另一个 shell 脚本中?
-
因为我想让其他用户不能使用Jenkins系统配置任何东西,所有构建相关的脚本都将由git管理。
-
奇数。尽管如此,如果它都在 git 中,那么为什么不使用 pipeline 和 Jenkinsfile](jenkins.io/doc/book/pipeline/jenkinsfile) 而不是 shell 步骤?
标签: jenkins