如何通过 REST API 创建 jenkins 凭证? [英] How to create jenkins credentials via the REST API?

查看:39
本文介绍了如何通过 REST API 创建 jenkins 凭证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个 jenkins 凭证(https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Plugin ) 通过脚本.我如何使用 REST API 或 cli 来做到这一点?

I need to create a jenkins credential ( https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Plugin ) via a script. How can I do that using either the REST API or the cli ?

请注意,我可以使用/credential-store/domain//api/json 和/credential-store/domain//credential/8bd82461-e239-4db1-90bc 列出凭据-831ca3412​​e70/api/json 等

Note that I'm able to list the credentials using /credential-store/domain//api/json and /credential-store/domain//credential/8bd82461-e239-4db1-90bc-831ca3412e70/api/json etc.

推荐答案

这个问题花了我一段时间才弄明白,我想了很多,所以我决定把解决方案放在这里,如果其他人需要它.

This issue took me a while to figure, a lot of digging around, so I decided to let the solution here, if someone else needs it.

curl -X POST 'http://user:token@jenkins_server:8080/credentials/store/system/domain/_/createCredentials' 
--data-urlencode 'json={
  "": "0",
  "credentials": {
    "scope": "GLOBAL",
    "id": "identification",
    "username": "manu",
    "password": "bar",
    "description": "linda",
    "$class": "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
  }
}'

这篇关于如何通过 REST API 创建 jenkins 凭证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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