如何从命令行重置 Jenkins 安全设置? [英] How to reset Jenkins security settings from the command line?
问题描述
有没有办法在没有用户/密码的情况下从命令行重置所有(或仅禁用安全设置),因为我已经设法将自己完全锁定在 Jenkins
之外?
Is there a way to reset all (or just disable the security settings) from the command line without a user/password as I have managed to completely lock myself out of Jenkins
?
推荐答案
最简单的解决方案是完全禁用安全性 - 将 /var 中的
文件.true
更改为 false
/lib/jenkins/config.xml
The simplest solution is to completely disable security - change true
to false
in /var/lib/jenkins/config.xml
file.
<useSecurity>true</useSecurity>
实现相同的单线:
sed -i 's/<useSecurity>true</useSecurity>/<useSecurity>false</useSecurity>/g' /var/lib/jenkins/config.xml
然后重启詹金斯:
sudo service jenkins restart
然后转到管理面板并再次设置所有内容.
And then go to admin panel and set everything once again.
如果您在 Kubernetes pod 中运行 Jenkins 并且无法运行 service
命令,那么您可以通过删除 pod 来重新启动 Jenkins:
If you in case are running your Jenkins inside a Kubernetes pod and can not run service
command, then you can just restart Jenkins by deleting the pod:
kubectl delete pod <jenkins-pod-name>
一旦发出命令,Kubernetes 将终止旧 Pod 并启动一个新 Pod.
Once the command was issued, Kubernetes will terminate the old pod and start a new one.
这篇关于如何从命令行重置 Jenkins 安全设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!