在通过API詹金斯创建用户

编程入门 行业动态 更新时间:2024-10-08 04:29:42
本文介绍了在通过API詹金斯创建用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在想,如果我可以用它的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詹金斯创建用户

本文发布于:2023-11-28 11:47:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642276.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:金斯   用户   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!