jenkins - Jenkins,构建执行 shell,在 ubuntu 上更改 shell 运行用户
问题描述
我正在尝试在我的 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”时,如何将用户更改为其他用户?
解决方案
您可以/etc/sysconfig/jenkins
在所有 jenkins 相关信息存在的地方更改 JENKINS_USER。
然后 shell 命令将在您的主服务器上与该用户一起运行。
如果在代理上运行,那么您可以配置应连接的用户代理。
推荐阅读
- amazon-web-services - Kinesis 分片迭代器解释
- json - 无法使用 Angular 6 读取 meteo 网站 REST api 上的 JSON 数据
- postgresql - Postgres 数据库转储不想在 Docker 容器中导入
- javascript - 在正确的上下文中执行 Onload 属性 js
- python - 如何使用python从excel中的特定列中提取不可见的评论
- java - Vaadin 组合框返回 null
- java - 在 Leanft 中获取 MessageTypeNotSupportedException
- javascript - 在 React 项目中导入库
- html - 引导 4 卡 - 具有可变标题行行的垂直对齐主体
- c - 查找与一个字符串的结尾和下一个字符串的开头匹配的最长子字符串