我想通过 ansible 创建 jenkins 凭据 [英] I want to create jenkins credentials via ansible
问题描述
我正在使用 ansible 组装一台开发机器.在那台机器上,我正在安装 jenkins.
I am putting together a developer machine using ansible. In that machine i am installing jenkins.
我用 ansible 为 jenkins 创建了工作:
I have created the jobs for jenkins with ansible:
- shell: "java -jar {{ jenkins.cli_jar }} -s {{ jenkins.server }} create-job \
{{ item.name }} < {{ jenkins.jobs_dir }}/{{ item.xml_file }}"
with_items: "jenkins.jobs"
并通过cli等安装插件
And installed the plugins, via cli etc.
但是现在我缺少作业的 ssh 凭据;我只想要一个用户jenkins"的 ssh 凭据,并且使用来自 Jenkins 主服务器 ~/.ssh".
But now i am missing the ssh credentials for the jobs; i just want a ssh credential with user "jenkins" and that uses "From the Jenkins master ~/.ssh".
这种类型的凭据就是我所说的:
This type of credentials are the ones i am talking about:
也许是一个很棒的脚本,但我还没有找到很多关于它的信息.感谢您的帮助.
Maybe is a groovy script but i haven't find a lot of information about it. Thanks for the help.
推荐答案
Jenkins 凭据插件不允许使用 API 创建凭据 (https://issues.jenkins-ci.org/browse/JENKINS-28407).
Jenkins credentials plugin doesn't allow credentials creation using API (https://issues.jenkins-ci.org/browse/JENKINS-28407).
一个可行的解决方案是使用您喜欢的浏览器和 JMeter 代理或 Selenium IDE 记录凭证创建.并使用 JMeter CLI 重放它或将 Selenium 记录的测试保存为 groovy 脚本.
A viable solution would be recording a credential creation using your prefered browser and JMeter proxy or Selenium IDE. and replaying it using JMeter CLI or saving the Selenium recorded test as a groovy script.
你也可以看看 https://github.com/jenkinsci/credentials-插件/拉/33
这篇关于我想通过 ansible 创建 jenkins 凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!