我在想,如果我可以用它的API,我可以创造就业机会,创造詹金斯一个新用户,但对于詹金斯的API文档不具有与用户创造任何东西。
I was wondering if I can create a new user in jenkins using its api , I can create jobs , but the api docs for jenkins doesn't have anything related to user creation.
其实我要创建一个新用户之后为用户创建一个新的工作,这一切使用的API。
Actually i have to create a new user followed by creating a new job for that user ,all of this using an api.
谢谢Shubham
Thanks Shubham
推荐答案Shubham,
你说的没错,有一个添加一个用户没有明确的CLI命令。但你可以使用这个Groovy脚本(使用CLI执行)。
you're right, there is no explicit CLI command for adding a user. But you could use groovy script for this (using the CLI for execution).
细节取决于你的詹金斯的配置方式。例如,如果你的詹金斯使用自己的用户数据库,那么你可以通过下面的CLI调用添加一个新用户:
The details depend on how your Jenkins is configured. For example, if your Jenkins uses its own user database, then you could add a new user by the following CLI call:
echo 'jenkins.model.Jenkins.instance.securityRealm.createAccount("user1", "password123")' | java -jar jenkins-cli.jar -s localhost/ groovy =这个shell命令将创建登录user1和密码password123的新用户。这里的回声送至一个詹金斯CLI线常规code的(注意, = 表示CLI应得到标准输入code)。
This shell command will create a new user with login "user1" and password "password123". Here echo feeds a line of groovy code to a Jenkins CLI (note that = means that CLI should receive code from STDIN).
此外Groovy脚本可以管理用户权限,但是,确切的$ C $,c取决于使用什么授权策略。你可以使用此示例脚本的作为一个开始。
Also groovy script allows to manage user permissions, however, the exact code depends on what authorization strategy is used. You could use this sample script as a start.
问候,尼克
更多推荐
在通过API詹金斯创建用户
发布评论