一詹金斯用户认证信息如何能够与QUOT;通过"到使用詹金斯API来创造就业机会的脚本?

问题描述:

我有一个脚本,删除并重新创建通过HTTP卷曲通话工作,我想摆脱任何硬codeD的用户名:密码。
例如。 卷曲-X POST $网址--user用户名:密码

I have a script that delete and re-create jobs through curl HTTP-calls and I want to get rid of any hard-coded "username:password". E.g. curl -X POST $url --user username:password

注意事项:


  • 詹金斯CLI (可能不是一个选项)。
    一个人应该能够实现与CLI一样与詹金斯API(创造就业机会等),但据我了解詹金斯CLI是不是一个很好的选择了我,因为重新启动或刷新后创建只会出现在詹金斯工作从磁盘安装配置,这将取消任何其他正在运行的作业。

  • Jenkins CLI (probably not an option). One should be able to achieve the same with the CLI as with Jenkins API (creating jobs etc) but as far as I understand Jenkins CLI is not a good alternative for me since jobs created with will only appear in Jenkins after restarting or a "Reload Configuration from Disk", and that would cancel any other running jobs.

API令牌。不能找出如何让用户令牌,然后将它传递
作为参数传递给脚本,但可能是一个解决办法。

API token. Can't find out how to get the user token and then pass it as a parameter to the script, but that may be a solution..

试试这个方法:(例如删除作业)

Try this way: (for example delete the job)

curl --silent --show-error http://<username>:<api-token>@<jenkins-server>/job/<job-name>/doDelete

该API令牌可以从以下地址获得的http://&LT;詹金斯服务器&GT; /用户/&lt;用户名&GT; /配置