How to create Jenkins user by command line and GUI

In our previous post, we did installation of Jenkins on Ubuntu 18.04 LTS server. Now in this post we will learn to create Jenkins user by command line and GUI method.

In this article, we will use the term JENKINS_URL, it means the URL of your Jenkins server. For example – http://localhost:8080 or https://localhost. Therefor, replace the value of JENKINS_URL with your Jenkins URL wherever you find in this post.

Here, we are creating user in ‘Jenkins’ own user database’. In ‘Configure Global Security’ page of Jenkins at ‘Access Control’ you will find 4 options for ‘Security Ream’, “Jenkins’ own user database” is one of them.
Note: In Web browser JENKINS_URL/configureSecurity/ will open the “Configure Global Security” page. Change value of JENKINS_URL with your jenkins http or htps url.

Screenshot of ‘Configure Global Security’:

Create new Jenkins user through command line(CLI)

We will run the command line from Jenkins server itself. We can also run the command remotely too,for this you have to download ‘jenkins-cli.jar’ in your remote system.

Creating Jenkins user through command line is very useful, you can easily automate this step by writing your own script.

  1. Login to your Jenkins Server through ssh
  2. Download jenkins-cli.jar:
    Syntax: wget JENKINS_URL/jnlpJars/jenkins-cli.jar

    wget http://localhost:8080/jnlpJars/jenkins-cli.jar

    After downloading, next step is to execute the command.

  3. Create Jenkins user by cli:
    You should run this command from location where you have downloaded jenkins-cli.jar file.
    Syntax:echo 'jenkins.model.Jenkins.instance.securityRealm.createAccount("NEW_USER", "NEW_USER_PASSWORD")' | java -jar ./jenkins-cli.jar -s "JENKINS_URL" -auth JENKINS_ADMIN_USER:JENKINS_ADMIN_PASSWORD -noKeyAuth groovy = –

    NEW_USER: New Jenkins user name
    NEW_USER_PASSWORD: Password of new Jenkins user
    JENKINS_URL: Your Jenkins Server URL
    JENKINS_ADMIN_USER: Jenkins admin user name
    JENKINS_ADMIN_PASSWORD: Jenkins admin password


    echo 'jenkins.model.Jenkins.instance.securityRealm.createAccount("test", "test123")' | java -jar ./jenkins-cli.jar -s "http://localhost:8080" -auth admin:admin123 -noKeyAuth groovy = –

Through command line created Jenkins user you can verify in console
, here is its URL path JENKINS_URL/securityRealm/.

Create Jenkins user by GUI

From GUI(Graphical User Interface), you can easily create Jenkins User.

Navigation Path:
Manage Jenkins >> Manage Users >> Create User. Fill the form and click ‘Create User’ button.

create Jenkins user

create Jenkins user

create Jenkins user GUI

create Jenkins user

create Jenkins user GUI

Rather going through with each click-click way, you can directly open JENKINS_URL/securityRealm/ this URL path for user creation console.

Creating the Jenkns User is easy and one of the important part of security also. It is recommended to safe Jenkins admin user, create new user and grant necessary permission to it.