Bird
Raised Fist0
Jenkinsdevops~20 mins

Jenkins configuration as code (JCasC) - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
JCasC Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
JCasC YAML Loading Behavior
Given this Jenkins Configuration as Code (JCasC) YAML snippet, what will be the output when Jenkins loads it?
jenkins:
  systemMessage: "Welcome to Jenkins"
  numExecutors: 3
  securityRealm:
    local:
      allowsSignup: false
      users:
        - id: "admin"
          password: "admin123"
AJenkins fails to load the configuration due to missing 'authorizationStrategy' section and throws an error.
BJenkins ignores the 'numExecutors' setting and uses default 2 executors, but sets system message and user correctly.
CJenkins sets system message to 'Welcome to Jenkins', number of executors to 3, and creates a local user 'admin' with password 'admin123'.
DJenkins sets system message and executors but does not create any users because 'users' list is empty.
Attempts:
2 left
💡 Hint
Check if the YAML defines required fields for system message, executors, and local users.
❓ Troubleshoot
intermediate
2:00remaining
Troubleshooting JCasC Plugin Failure
You applied a JCasC YAML file to Jenkins but the configuration did not apply and Jenkins logs show:
java.lang.IllegalArgumentException: No enum constant jenkins.security.s2m.AdminWhitelistRule

What is the most likely cause?
AThe YAML file contains an invalid value for the 'authorizationStrategy' field.
BThe Jenkins instance is missing the JCasC plugin entirely.
CThe Jenkins home directory is not writable by the Jenkins process.
DThe YAML file is missing the 'jenkins' root key.
Attempts:
2 left
💡 Hint
Look at the error mentioning 'No enum constant' related to security.
❓ Configuration
advanced
2:00remaining
Configuring Jenkins Global Tools with JCasC
Which YAML snippet correctly configures a JDK installation named 'jdk11' with JAVA_HOME '/usr/lib/jvm/java-11-openjdk' using Jenkins Configuration as Code?
A
tool:
  jdk:
    installations:
      - name: "jdk11"
        home: "/usr/lib/jvm/java-11-openjdk"
B
jenkins:
  tools:
    jdk:
      installations:
        - name: "jdk11"
          home: "/usr/lib/jvm/java-11-openjdk"
C
jenkins:
  tool:
    jdk:
      installations:
        - name: "jdk11"
          home: "/usr/lib/jvm/java-11-openjdk"
D
tools:
  jdk:
    installations:
      - name: "jdk11"
        home: "/usr/lib/jvm/java-11-openjdk"
Attempts:
2 left
💡 Hint
Global tools are configured under the 'jenkins' root key and 'tools' section.
🔀 Workflow
advanced
2:00remaining
JCasC and Pipeline Job Creation
You want to create a Jenkins pipeline job named 'build-app' using JCasC. Which approach is correct?
AUse JCasC to configure Jenkins system only; jobs must be created manually.
BJCasC does not support job creation; use Job DSL or REST API instead.
CCreate a seed job with Job DSL and then export its configuration to JCasC YAML.
DDefine the pipeline job under 'jobs:' section in JCasC YAML with its pipeline script inline.
Attempts:
2 left
💡 Hint
JCasC supports job definitions under a specific section.
✅ Best Practice
expert
2:00remaining
Best Practice for Managing Secrets in JCasC
What is the recommended way to manage sensitive credentials when using Jenkins Configuration as Code (JCasC)?
AUse Jenkins Credentials Plugin and reference credentials by ID in JCasC YAML without storing secrets in the YAML.
BStore all secrets directly in the JCasC YAML file encrypted with a custom key.
CEmbed secrets as plain text in the JCasC YAML but restrict file system permissions tightly.
DUse environment variables in the JCasC YAML to inject secrets at runtime.
Attempts:
2 left
💡 Hint
Consider security best practices for secret management in Jenkins.

Practice

(1/5)
1. What is the main purpose of Jenkins Configuration as Code (JCasC)?
easy
A. To monitor Jenkins server performance
B. To write Jenkins plugins in Java
C. To define Jenkins setup using a YAML file for easy automation
D. To create Jenkins jobs manually through the UI

Solution

  1. Step 1: Understand JCasC concept

    JCasC allows Jenkins setup to be described in a YAML file instead of manual UI steps.
  2. Step 2: Identify the main benefit

    This YAML file makes automation, sharing, and repeating Jenkins setup easy and safe.
  3. Final Answer:

    To define Jenkins setup using a YAML file for easy automation -> Option C
  4. Quick Check:

    JCasC = YAML setup automation [OK]
Hint: JCasC means Jenkins setup in YAML file [OK]
Common Mistakes:
  • Confusing JCasC with plugin development
  • Thinking JCasC is for manual UI job creation
  • Assuming JCasC monitors performance
2. Which of the following is the correct syntax to define Jenkins system message in a JCasC YAML file?
easy
A. jenkins: systemMessage: "Welcome to Jenkins!"
B. jenkins: system_message: "Welcome to Jenkins!"
C. jenkins: system-message: "Welcome to Jenkins!"
D. jenkins: system message: "Welcome to Jenkins!"

Solution

  1. Step 1: Check YAML key naming conventions

    JCasC uses camelCase keys matching Jenkins config names, so 'systemMessage' is correct.
  2. Step 2: Validate YAML syntax

    jenkins: systemMessage: "Welcome to Jenkins!" uses correct key and proper YAML indentation and quotes.
  3. Final Answer:

    jenkins:\n systemMessage: "Welcome to Jenkins!" -> Option A
  4. Quick Check:

    Correct key is systemMessage in YAML [OK]
Hint: Use camelCase keys exactly as Jenkins expects [OK]
Common Mistakes:
  • Using underscores instead of camelCase
  • Using spaces or dashes in keys
  • Incorrect YAML indentation
3. Given this JCasC snippet, what will be the Jenkins admin username after applying it?
jenkins:
  securityRealm:
    local:
      allowsSignup: false
      users:
        - id: "admin"
          password: "admin123"
medium
A. root
B. user
C. guest
D. admin

Solution

  1. Step 1: Read the users list in securityRealm

    The YAML defines one user with id 'admin' and password 'admin123'.
  2. Step 2: Identify the admin username

    The user id 'admin' is the admin username set by this config.
  3. Final Answer:

    admin -> Option D
  4. Quick Check:

    User id in YAML = admin [OK]
Hint: Look for 'id' under users in securityRealm [OK]
Common Mistakes:
  • Assuming default username instead of YAML value
  • Confusing password with username
  • Ignoring YAML indentation and structure
4. You applied this JCasC YAML but Jenkins failed to start:
jenkins:
  systemMessage "Hello Jenkins!"
What is the error in this configuration?
medium
A. Incorrect indentation of systemMessage
B. Missing colon ':' after systemMessage key
C. systemMessage should be under securityRealm
D. Quotes around Hello Jenkins! are not allowed

Solution

  1. Step 1: Check YAML key-value syntax

    YAML requires a colon ':' after keys to separate them from values.
  2. Step 2: Identify missing colon

    The line 'systemMessage "Hello Jenkins!"' misses the colon after systemMessage.
  3. Final Answer:

    Missing colon ':' after systemMessage key -> Option B
  4. Quick Check:

    YAML key:value needs colon [OK]
Hint: YAML keys must have colon ':' before values [OK]
Common Mistakes:
  • Forgetting colon after key
  • Misplacing keys under wrong parent
  • Thinking quotes are forbidden
5. You want to automate Jenkins setup with JCasC to create two users: 'alice' and 'bob'. Which YAML snippet correctly defines both users with passwords?
hard
A. jenkins: securityRealm: local: allowsSignup: false users: - id: "alice" password: "alicePass" - id: "bob" password: "bobPass"
B. jenkins: securityRealm: local: allowsSignup: false users: id: "alice" password: "alicePass" id: "bob" password: "bobPass"
C. jenkins: securityRealm: local: allowsSignup: false users: alice: "alicePass" bob: "bobPass"
D. jenkins: securityRealm: local: allowsSignup: false users: - alice: "alicePass" - bob: "bobPass"

Solution

  1. Step 1: Understand users list format

    Users must be a list of maps with 'id' and 'password' keys for each user.
  2. Step 2: Check each option's structure

    jenkins: securityRealm: local: allowsSignup: false users: - id: "alice" password: "alicePass" - id: "bob" password: "bobPass" correctly uses a list with '- id' and 'password' pairs for alice and bob.
  3. Final Answer:

    jenkins:\n securityRealm:\n local:\n allowsSignup: false\n users:\n - id: "alice"\n password: "alicePass"\n - id: "bob"\n password: "bobPass" -> Option A
  4. Quick Check:

    Users list with id/password pairs = jenkins: securityRealm: local: allowsSignup: false users: - id: "alice" password: "alicePass" - id: "bob" password: "bobPass" [OK]
Hint: Users must be list items with id and password keys [OK]
Common Mistakes:
  • Defining users as a map instead of list
  • Repeating keys without list dash
  • Using username as key instead of id
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