Jenkins CLI get-job与Role-Based Strategy的那点事
Posted on 2013-06-13 15:58 Bruce Zhang 阅读(1462) 评论(0) 编辑 收藏 举报最近在写两个Jenkins之间的JOB同步插件。
在测试的过程中,发现Jenkins CLI命令中的get-job、update-job、rename-job(这个是我的插件中集成进去的,官方没有提供)和Role-Based Strategy有点奸情。
背景:Jenkins 1.5.18 + Role-based Authorization Strategy 1.1.2
具体现象:create-job、delete-job、list-jobs等可以正常使用,但是get-job、update-job、rename-job则报错,并提示“No such job xxxx”。
C:\> java -jar jenkins-cli.jar -s http://<ip>:8080/ get-job test --username <admin_name> --password <admin_password>
No such job 'test' java -jar jenkins-cli.jar get-job args... Dumps the job definition XML to stdout JOB : Name of the job --username VAL : User name to authenticate yourself to Jenkins --password VAL : Password for authentication. Note that passing a password in arguments is insecure. --password-file VAL : File that contains the password
结论:
必须保证“Anonymous”账户拥有JOB的读权限:
论证过程:
分别去掉/加上“Anonymous”账户的read job权限,然后运行:
java -jar jenkins-cli.jar -s http://<ip>:8080/ get-job test --username <admin_name> --password <admin_password>