在Jenkins中以其他用户身份运行构建步骤 [英] Runbuild steps as a different user in Jenkins

查看:370
本文介绍了在Jenkins中以其他用户身份运行构建步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用集中式詹金斯设置,该设置用于为不同组构建项目.詹金斯人以用户u1的身份运行.不同项目中的一些测试用例需要一些权限,这些权限仅授予特定用户u2,u3等的分组.我想从我的jenkins中以u2的身份运行测试用例.

I use a centralized jenkins setup that is used to build projects for different groups. The jenkins is run as user u1. Some of test cases in different projects require some permission that is granted only to group specific user u2, u3 etc. I want to run the test cases as u2 from my jenkins.

如何在Jenkins中以不同于jenkins运行用户的用户身份运行maven/ant目标. 我不想将从节点启动为u2,因为它可以运行除测试命令以外的任何命令.

How in Jenkins can I run the maven/ant target as a different user than jenkins run user. I do not want to launch a slave node as u2 because that can run any command than just the test command.

如果您有任何建议,请告诉我.

Please let me know if you have any suggestion.

谢谢

推荐答案

这取决于操作系统.您将无法使用jenkins中的maven/ant插件运行maven/ant目标,因为它使用了jenkins从属运行的任何用户.您将必须运行类型为执行外壳脚本"或执行Windows批处理命令"的构建步骤.在批处理文件中,您将需要使用

It depends on the OS. You won't be able to run the maven/ant target using the maven/ant plugin in jenkins, since it uses whatever user the jenkins slave is running under. You would have to run a build step of type "Execute shell script" Or "Execute windows batch command" In your batch file, you would need to use

runas /user:<machine>\u2 ant <target>

或在Linux上

su -c "ant <target>" u2

这篇关于在Jenkins中以其他用户身份运行构建步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆