如何在Jenkins中通过shell命令给予用户管理员权限

waxmsbnn  于 2022-12-11  发布在  Jenkins
关注(0)|答案(2)|浏览(374)

意外地,我在Jenkins中不再具有 * 管理员 * 权限。
看来一切正常。
Jenkins日志:

Jul 24, 2016 12:40:51 AM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Workspace clean-up. 7 ms
Jul 24, 2016 4:38:30 AM hudson.model.Run execute
INFO: job1 #91 main build action completed: FAILURE
Jul 24, 2016 4:38:39 AM hudson.model.Run execute
INFO: job2 #10 main build action completed: SUCCESS
Jul 24, 2016 9:10:18 AM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: While serving http://192.168.23.88:8080/restart: hudson.security.AccessDeniedException2: 
ali71 is missing the Overall/Administer permission

如何使用shell命令为我的帐户设置 * 管理员 * 权限?

polhcujo

polhcujo1#

由于您无法针对Jenkins进行身份验证,因此您(AFAIK)必须首先禁用安全性。

警告:请勿在公共可访问的Jenkins安装上执行此操作!

通过SSH连接到Jenkins服务器并修改Jenkins主目录中的config.xml

<useSecurity>true</useSecurity>

暂时到

<useSecurity>false</useSecurity>

以便重新给予您管理员权限。然后根据您的需要启用和配置安全性。
请注意,在此期间访问Jenkins的任何其他人都具有 * 管理员 * 权限。
the Jenkins Wiki中也描述了此过程。

8yparm6h

8yparm6h2#

请转到config.xml并将此部分临时添加到角色中,它将向分配了此角色的用户给予管理权限。

<role name="admin" pattern=".*">
    <permissions>
      <permission>hudson.model.View.Delete</permission>
      <permission>hudson.model.Computer.Connect</permission>
      <permission>hudson.model.Run.Delete</permission>
      <permission>com.cloudbees.plugins.credentials.CredentialsProvider.ManageDomains</permission>
      <permission>hudson.model.Computer.Create</permission>
      <permission>hudson.model.View.Configure</permission>
      <permission>hudson.model.Computer.Build</permission>
      <permission>hudson.model.Item.Configure</permission>
      <permission>hudson.model.Hudson.Administer</permission>
      <permission>hudson.model.Item.Cancel</permission>
      <permission>hudson.model.Item.Read</permission>
      <permission>com.cloudbees.plugins.credentials.CredentialsProvider.View</permission>
      <permission>hudson.model.Computer.Delete</permission>
      <permission>hudson.model.Item.Build</permission>
      <permission>org.jenkins.plugins.lockableresources.LockableResourcesManager.Unlock</permission>
      <permission>hudson.scm.SCM.Tag</permission>
      <permission>hudson.model.Item.Move</permission>
      <permission>hudson.model.Item.Discover</permission>
      <permission>hudson.model.Hudson.Read</permission>
      <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Update</permission>
      <permission>hudson.model.Item.Create</permission>
      <permission>hudson.model.Item.Workspace</permission>
      <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Delete</permission>
      <permission>hudson.model.Computer.Provision</permission>
      <permission>hudson.model.Run.Replay</permission>
      <permission>hudson.model.View.Read</permission>
      <permission>org.jenkins.plugins.lockableresources.LockableResourcesManager.View</permission>
      <permission>hudson.model.View.Create</permission>
      <permission>hudson.model.Item.Delete</permission>
      <permission>hudson.model.Computer.Configure</permission>
      <permission>com.cloudbees.plugins.credentials.CredentialsProvider.Create</permission>
      <permission>hudson.model.Computer.Disconnect</permission>
      <permission>org.jenkins.plugins.lockableresources.LockableResourcesManager.Reserve</permission>
      <permission>hudson.model.Run.Update</permission>

相关问题