以编程方式更改jenkins工作凭证

时间:2018-05-21 11:50:38

标签: jenkins

我有一个jenkins设置,有大量的工作。 我想将所有从git克隆的凭据更改为凭证Y(我已创建) 有没有办法以编程方式做到这一点?

感谢

2 个答案:

答案 0 :(得分:0)

如果您尚未配置git凭证帮助程序(请与git config credential.helper联系),请设置一个(例如git config credential.helper store)。

然后,您可以使用

以编程方式存储凭据

printf "username=<your_username>\npassword=<your_password>\nprotocol=https\nhost=your.git.host.net\n\n" | git credential approve

答案 1 :(得分:0)

我最后只对/ var / lib / jenkins / jobs中的所有xml文件执行sed命令,并将凭证ID替换为新的id。 不是那么优雅,而是像魅力一样工作