Bird
Raised Fist0
Jenkinsdevops~20 mins

System configuration management in Jenkins - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Jenkins System Configuration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Jenkins CLI: List all installed plugins
What is the output of the following Jenkins CLI command when run on a Jenkins server with plugins installed?
Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080/ list-plugins
ALists all plugins with their versions and enabled/disabled status
BShows an error: 'list-plugins' is not a valid command
COutputs only the names of plugins without versions
DReturns an empty list even if plugins are installed
Attempts:
2 left
💡 Hint
Think about what the 'list-plugins' command is designed to show in Jenkins CLI.
❓ Configuration
intermediate
2:00remaining
Jenkins Pipeline: Correct syntax for environment variables
Which Jenkins Pipeline snippet correctly sets environment variables for use in the pipeline?
Jenkins
pipeline {
  agent any
  environment {
    VAR1 = 'value1'
    VAR2 = 'value2'
  }
  stages {
    stage('Example') {
      steps {
        echo "VAR1 is ${VAR1} and VAR2 is ${VAR2}"
      }
    }
  }
}
A
environment {
  VAR1 => 'value1'
  VAR2 => 'value2'
}
B
environment {
  VAR1: 'value1'
  VAR2: 'value2'
}
C
environment {
  'VAR1' = 'value1'
  'VAR2' = 'value2'
}
D
environment {
  VAR1 = 'value1'
  VAR2 = 'value2'
}
Attempts:
2 left
💡 Hint
Look at the correct syntax for environment variables in Jenkins declarative pipeline.
🔀 Workflow
advanced
2:30remaining
Jenkins Job DSL: Creating a freestyle job with parameters
Which Job DSL script correctly creates a freestyle Jenkins job named 'BuildApp' with a string parameter 'BRANCH' defaulting to 'main'?
A
job('BuildApp') {
  parameters {
    stringParameter('BRANCH', 'main', 'Git branch to build')
  }
}
B
job('BuildApp') {
  parameters {
    string('BRANCH', 'main', 'Git branch to build')
  }
}
C
job('BuildApp') {
  parameters {
    stringParam('BRANCH', 'main', 'Git branch to build')
  }
}
D
job('BuildApp') {
  parameters {
    paramString('BRANCH', 'main', 'Git branch to build')
  }
}
Attempts:
2 left
💡 Hint
Check the exact method name for string parameters in Jenkins Job DSL.
❓ Troubleshoot
advanced
2:30remaining
Jenkins Pipeline: Diagnosing a syntax error in a scripted pipeline
Given this Jenkins scripted pipeline snippet, what error will Jenkins report?
Jenkins
node {
  stage('Build') {
    echo 'Building...'
  }
  stage('Test')
    echo 'Testing...'
  }
}
ANo error, pipeline runs successfully
BSyntaxError: expecting '{' after stage declaration
CRuntimeException: stage 'Test' not found
DGroovyCastException: Cannot cast String to Closure
Attempts:
2 left
💡 Hint
Look carefully at the braces and structure after the 'stage('Test')' line.
✅ Best Practice
expert
3:00remaining
Jenkins Configuration as Code (JCasC): Correct YAML snippet for global security
Which YAML snippet correctly disables Jenkins security using Configuration as Code (JCasC)?
A
jenkins:
  securityRealm:
    none: {}
  authorizationStrategy:
    anyoneCanDoAnything: {}
B
jenkins:
  securityRealm:
    local:
      allowsSignup: true
      users: []
  authorizationStrategy:
    anyoneCanDoAnything: false
C
jenkins:
  securityRealm:
    local:
      allowsSignup: false
      users: []
  authorizationStrategy:
    loggedInUsersCanDoAnything: false
D
jenkins:
  securityRealm:
    none: {}
  authorizationStrategy:
    loggedInUsersCanDoAnything: true
Attempts:
2 left
💡 Hint
Disabling security means no authentication required and full access for anyone including anonymous users.

Practice

(1/5)
1. What is the main purpose of system configuration management in Jenkins?
easy
A. To write code for Jenkins plugins
B. To monitor Jenkins server performance
C. To automate setting up and maintaining computer systems
D. To create user accounts in Jenkins

Solution

  1. Step 1: Understand system configuration management

    It automates the setup and maintenance of computer systems to keep them consistent.
  2. Step 2: Relate to Jenkins usage

    Jenkins uses this to run tools like Ansible or Puppet to automate system setup.
  3. Final Answer:

    To automate setting up and maintaining computer systems -> Option C
  4. Quick Check:

    System configuration management = automation of system setup [OK]
Hint: Think automation of system setup and maintenance [OK]
Common Mistakes:
  • Confusing system config with Jenkins plugin development
  • Thinking it monitors Jenkins server only
  • Assuming it manages Jenkins user accounts
2. Which Jenkins pipeline step correctly runs an Ansible playbook named setup.yml?
easy
A. sh 'ansible-playbook setup.yml'
B. ansiblePlaybook 'setup.yml'
C. run ansible setup.yml
D. execute 'ansible-playbook setup.yml'

Solution

  1. Step 1: Identify correct Jenkins pipeline syntax for shell commands

    Jenkins uses sh step to run shell commands.
  2. Step 2: Check Ansible command correctness

    The correct command is ansible-playbook setup.yml.
  3. Final Answer:

    sh 'ansible-playbook setup.yml' -> Option A
  4. Quick Check:

    Use sh for shell commands in Jenkins [OK]
Hint: Use 'sh' step for shell commands in Jenkins pipeline [OK]
Common Mistakes:
  • Using non-existent Jenkins steps like ansiblePlaybook
  • Omitting the 'sh' wrapper for shell commands
  • Using incorrect command syntax
3. Given this Jenkins pipeline snippet:
pipeline {
  agent any
  stages {
    stage('Config') {
      steps {
        sh 'ansible-playbook -i inventory setup.yml'
      }
    }
  }
}

What happens when this pipeline runs?
medium
A. Jenkins runs the Ansible playbook setup.yml using the inventory file
B. Jenkins fails because sh cannot run Ansible
C. Jenkins skips the stage because no agent is specified
D. Jenkins runs the playbook but ignores the inventory file

Solution

  1. Step 1: Understand the sh step in Jenkins pipeline

    The sh step runs shell commands on the agent.
  2. Step 2: Analyze the command ansible-playbook -i inventory setup.yml

    This runs the Ansible playbook setup.yml using the specified inventory file.
  3. Final Answer:

    Jenkins runs the Ansible playbook setup.yml using the inventory file -> Option A
  4. Quick Check:

    sh runs shell commands, so Ansible runs as expected [OK]
Hint: Remember sh runs shell commands exactly [OK]
Common Mistakes:
  • Thinking Jenkins cannot run Ansible via shell
  • Assuming agent is missing and stage skips
  • Ignoring the inventory file in command
4. You wrote this Jenkins pipeline step:
sh 'ansible-playbook setup.yml -i inventory'

But the pipeline fails with "command not found" error. What is the likely cause?
medium
A. The playbook setup.yml has syntax errors
B. Ansible is not installed or not in PATH on the Jenkins agent
C. The sh step is incorrect syntax
D. The inventory file is missing

Solution

  1. Step 1: Understand "command not found" error

    This error means the shell cannot find the command ansible-playbook.
  2. Step 2: Check possible causes

    If Ansible is not installed or not in the PATH on the Jenkins agent, this error occurs.
  3. Final Answer:

    Ansible is not installed or not in PATH on the Jenkins agent -> Option B
  4. Quick Check:

    "command not found" means missing executable [OK]
Hint: "command not found" means missing program or PATH issue [OK]
Common Mistakes:
  • Assuming inventory file missing causes command not found
  • Thinking sh syntax is wrong
  • Blaming playbook syntax for command not found
5. You want Jenkins to ensure all your servers have the same configuration using Puppet. Which approach best fits system configuration management in Jenkins?
hard
A. Write Puppet manifests inside Jenkinsfile without running them
B. Manually log into each server and run Puppet commands
C. Use Jenkins only to build software, not for configuration
D. Create a Jenkins pipeline that runs Puppet agent commands on target servers

Solution

  1. Step 1: Understand Jenkins role in system configuration

    Jenkins automates running configuration tools like Puppet on servers.
  2. Step 2: Identify best practice

    Running Puppet agent commands via Jenkins pipeline automates and ensures consistency.
  3. Final Answer:

    Create a Jenkins pipeline that runs Puppet agent commands on target servers -> Option D
  4. Quick Check:

    Automation via Jenkins pipeline is best practice [OK]
Hint: Automate Puppet runs via Jenkins pipeline for consistency [OK]
Common Mistakes:
  • Manually running Puppet defeats automation purpose
  • Ignoring Jenkins for configuration management
  • Writing manifests but not executing them
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