2

I am trying to create a user and password for Jenkins using JCASC. I can set up Jenkins however when I go to the GUI on my local host I do not see any users. Here is my code

jenkins:
  systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n"
  disabledAdministrativeMonitors:
      - "jenkins.diagnostics.ControllerExecutorsNoAgents"
credentials:
  system:
    domainCredentials:
    - credentials:
      - usernamePassword:
          id: "admin-cred"
          username: "jenkins-admin"
          password: "butler"
          scope: GLOBAL

I believe I have all the necessary plugins installed but something is missing clearly. Any help would be appreciated.

Matt Salem
  • 75
  • 8
  • What you have done here is defined a credential for using an SCM, like git. `securityRealm` is used for Jenkins server's users – sayandcode Aug 14 '23 at 07:16

2 Answers2

2

The way I got users to pop up is by setting up the (local) security realm, rather than credentials, like so:

jenkins:
  securityRealm:
    local:
      users:
       - id: jenkins-admin
         password: butler

I'm finding this a great resource to get ideas from: https://github.com/oleg-nenashev/demo-jenkins-config-as-code

Nico Villanueva
  • 876
  • 8
  • 22
  • I tried that for another user. a.k.a, I have already admin defined, and then I tried to add another user, but jenkins doesn't create the second user. any thoughts? – hilaf Jan 02 '23 at 14:13
0

I've used a local security Realm with disabled signups to add the user "jenkins-admin".

jenkins:
    . . .
    securityRealm:
        local:
            allowsSignup: false
            users: 
                - id: jenkins-admin
                  password: butler

You can refer below links to know more about Jcasc:

  • I tried that for another user. a.k.a, I have already admin defined, and then I tried to add another user, but jenkins doesn't create the second user. any thoughts? – hilaf Jan 02 '23 at 14:12