Bird
Raised Fist0
Jenkinsdevops~10 mins

Creating first admin user in Jenkins - Interactive Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create the first admin user in Jenkins using the CLI.

Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080 create-user --username [1] --password admin123 --full-name "Admin User" --email admin@example.com
Drag options to blanks, or click blank then click option'
Aroot
Buser
Cguest
Dadmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'user' or 'guest' as the admin username causes access issues.
Using 'root' is incorrect because Jenkins does not use system usernames.
2fill in blank
medium

Complete the command to create the first admin user with the Jenkins CLI specifying the server URL.

Jenkins
java -jar jenkins-cli.jar -s [1] create-user --username admin --password admin123 --full-name "Admin User" --email admin@example.com
Drag options to blanks, or click blank then click option'
Ahttp://jenkins.local:8080
Bftp://jenkins.local
Chttps://jenkins.local:22
Dfile:///var/jenkins
Attempts:
3 left
💡 Hint
Common Mistakes
Using FTP or file URLs instead of HTTP causes connection failures.
Using HTTPS without proper setup may cause errors.
3fill in blank
hard

Fix the error in the command to create the first admin user by choosing the correct option for the password flag.

Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080 create-user --username admin [1] admin123 --full-name "Admin User" --email admin@example.com
Drag options to blanks, or click blank then click option'
A--pass
B--pwd
C--password
D-p
Attempts:
3 left
💡 Hint
Common Mistakes
Using short or incorrect flags like -p or --pass causes errors.
Misspelling the flag leads to command failure.
4fill in blank
hard

Fill both blanks to complete the Jenkins CLI command that creates the first admin user with username and password.

Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080 create-user --username [1] [2] admin123 --full-name "Admin User" --email admin@example.com
Drag options to blanks, or click blank then click option'
Aadmin
B--password
C--pass
Duser
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect password flags like --pass.
Using wrong usernames like 'user' instead of 'admin'.
5fill in blank
hard

Fill all three blanks to complete the Jenkins CLI command creating the first admin user with username, password flag, and email.

Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080 create-user --username [1] [2] admin123 --full-name "Admin User" --email [3]
Drag options to blanks, or click blank then click option'
Aadmin
B--password
Cadmin@example.com
Duser@example.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong email addresses.
Using short or incorrect password flags.

Practice

(1/5)
1. Why is it important to create the first admin user in Jenkins?
easy
A. To speed up the build process
B. To secure the Jenkins server by controlling access
C. To reduce the server's memory usage
D. To automatically install plugins

Solution

  1. Step 1: Understand Jenkins security basics

    Jenkins requires an admin user to control who can access and manage the server.
  2. Step 2: Recognize the role of the first admin user

    This user sets permissions and protects the server from unauthorized access.
  3. Final Answer:

    To secure the Jenkins server by controlling access -> Option B
  4. Quick Check:

    Security = Control access [OK]
Hint: First admin user controls access and security [OK]
Common Mistakes:
  • Thinking admin user speeds up builds
  • Confusing admin user with plugin installer
  • Believing admin user reduces memory use
2. Which of the following is the correct syntax to create a new admin user using Jenkins Groovy script console?
easy
A. jenkins.createUser('admin', 'password')
B. Jenkins.instance.createUser('admin', 'password')
C. Jenkins.security.createAccount('admin', 'password')
D. jenkins.model.Jenkins.instance.securityRealm.createAccount('admin', 'password')

Solution

  1. Step 1: Recall Jenkins Groovy script for user creation

    The correct method to create a user is via the securityRealm's createAccount method.
  2. Step 2: Match the exact syntax

    jenkins.model.Jenkins.instance.securityRealm.createAccount('admin', 'password') is the valid syntax.
  3. Final Answer:

    jenkins.model.Jenkins.instance.securityRealm.createAccount('admin', 'password') -> Option D
  4. Quick Check:

    securityRealm.createAccount = correct syntax [OK]
Hint: Use securityRealm.createAccount to add users [OK]
Common Mistakes:
  • Using Jenkins.instance.createUser which does not exist
  • Calling jenkins.createUser directly
  • Using Jenkins.security.createAccount which is invalid
3. What will be the result of running this Groovy script in Jenkins script console?
def instance = jenkins.model.Jenkins.instance
instance.securityRealm.createAccount('admin', 'admin123')
medium
A. Creates a new admin user named 'admin' with password 'admin123'
B. Throws an error because createAccount is undefined
C. Deletes the existing admin user
D. Changes the Jenkins system password

Solution

  1. Step 1: Analyze the script commands

    The script gets the Jenkins instance and calls createAccount on securityRealm with username and password.
  2. Step 2: Understand createAccount effect

    This method creates a new user with the given credentials in Jenkins.
  3. Final Answer:

    Creates a new admin user named 'admin' with password 'admin123' -> Option A
  4. Quick Check:

    createAccount adds user = Creates a new admin user named 'admin' with password 'admin123' [OK]
Hint: createAccount adds user with given name and password [OK]
Common Mistakes:
  • Assuming it deletes users
  • Expecting a system password change
  • Thinking createAccount is undefined
4. You tried to create the first admin user with this script:
jenkins.model.Jenkins.instance.securityRealm.createAccount('admin')

Why does it fail?
medium
A. Missing password argument in createAccount method
B. Incorrect method name, should be createUser
C. Jenkins instance is not accessible in script console
D. Username 'admin' is reserved and cannot be used

Solution

  1. Step 1: Check method parameters

    createAccount requires two parameters: username and password.
  2. Step 2: Identify missing argument

    The script only provides username, missing the password argument, causing failure.
  3. Final Answer:

    Missing password argument in createAccount method -> Option A
  4. Quick Check:

    Two arguments needed = Missing password argument in createAccount method [OK]
Hint: createAccount needs username and password [OK]
Common Mistakes:
  • Using wrong method name
  • Assuming Jenkins instance is inaccessible
  • Thinking 'admin' username is reserved
5. You want to automate creating the first admin user during Jenkins startup using an initialization Groovy script. Which approach is correct?
hard
A. Add the user credentials in config.xml directly
B. Run the createAccount command manually after Jenkins starts
C. Place a Groovy script with createAccount call in init.groovy.d directory
D. Modify Jenkins WAR file to include the user

Solution

  1. Step 1: Understand Jenkins initialization scripts

    Jenkins runs Groovy scripts placed in init.groovy.d folder during startup.
  2. Step 2: Automate user creation

    Placing a script with createAccount call there creates the admin user automatically on startup.
  3. Final Answer:

    Place a Groovy script with createAccount call in init.groovy.d directory -> Option C
  4. Quick Check:

    init.groovy.d scripts run at startup [OK]
Hint: Use init.groovy.d scripts for startup automation [OK]
Common Mistakes:
  • Trying manual commands only
  • Editing config.xml directly (not recommended)
  • Modifying Jenkins WAR file (complex and unsafe)
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard