0
0
Jenkinsdevops~20 mins

Creating first admin user in Jenkins - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Jenkins Admin User Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Jenkins CLI: Create Admin User Command Output
You run the Jenkins CLI command to create the first admin user with this script snippet:
java -jar jenkins-cli.jar -s http://localhost:8080/ groovy = <<EOF
import jenkins.model.*
import hudson.security.*

def instance = Jenkins.getInstance()

println(instance.securityRealm.createAccount("admin", "admin123"))
EOF

What will be the output?
Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080/ groovy = <<EOF
import jenkins.model.*
import hudson.security.*

def instance = Jenkins.getInstance()

println(instance.securityRealm.createAccount("admin", "admin123"))
EOF
Atrue
Bhudson.security.UserDetailsImpl@<hashcode>
Cnull
DSyntaxError: unexpected token
Attempts:
2 left
💡 Hint
The createAccount method returns a UserDetails object, not a boolean or null.
🧠 Conceptual
intermediate
1:30remaining
Understanding Jenkins Security Realm for Admin User Creation
Which Jenkins security realm setting allows you to create the first admin user by default when Jenkins is freshly installed?
AJenkins' own user database
BLDAP authentication
CUnix user/group database
DOAuth authentication
Attempts:
2 left
💡 Hint
The default Jenkins installation uses a built-in user database for authentication.
Troubleshoot
advanced
2:00remaining
Troubleshooting Jenkins Admin User Creation Failure
You tried to create the first admin user using a Groovy script in Jenkins CLI but got this error:
java.lang.NullPointerException: Cannot invoke method createAccount() on null object

What is the most likely cause?
AThe user already exists
BThe Groovy script syntax is incorrect
CThe Jenkins instance is not running
DThe securityRealm is not initialized because security is disabled
Attempts:
2 left
💡 Hint
If security is disabled, securityRealm is null and cannot create users.
🔀 Workflow
advanced
2:30remaining
Steps to Create First Admin User in Jenkins via Script
What is the correct order of steps to create the first admin user in Jenkins using a Groovy script?
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
You must first access CLI, then write and run script, then verify.
Best Practice
expert
3:00remaining
Best Practice for Securing First Admin User Creation in Jenkins
Which practice is best to secure the creation of the first admin user in Jenkins to avoid exposing credentials?
ADisable security temporarily to create users faster
BWrite passwords directly in Groovy scripts for simplicity
CUse environment variables to pass passwords instead of hardcoding in scripts
DShare admin credentials openly to team members for quick access
Attempts:
2 left
💡 Hint
Avoid putting passwords directly in code or sharing them openly.