0
0
Jenkinsdevops~10 mins

When to choose Jenkins - Interactive Code Practice

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

Complete the code to start a Jenkins pipeline with a simple stage.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        [1] 'echo Building...'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aexecute
Bsh
Crun
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'execute' which are not Jenkins pipeline steps.
2fill in blank
medium

Complete the code to trigger a Jenkins job remotely using a token.

Jenkins
curl -X POST http://jenkins.example.com/job/myjob/build?token=[1]
Drag options to blanks, or click blank then click option'
Amytoken123
Bpassword
Cusername
Dapikey
Attempts:
3 left
💡 Hint
Common Mistakes
Using username or password instead of token.
3fill in blank
hard

Fix the error in the Jenkinsfile to correctly define an environment variable.

Jenkins
pipeline {
  agent any
  environment {
    MY_VAR = [1]
  }
  stages {
    stage('Test') {
      steps {
        sh 'echo $MY_VAR'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
A'hello'
Bhello
C"hello"
DMY_VAR
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted values or single quotes which may cause errors.
4fill in blank
hard

Fill both blanks to create a Jenkins pipeline stage that runs only on the 'main' branch.

Jenkins
stage('Deploy') {
  when {
    [1] 'main'
  }
  steps {
    [2] 'echo Deploying to production'
  }
}
Drag options to blanks, or click blank then click option'
Abranch
Bsh
CnotEquals
Dbat
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'notEquals' or 'bat' which are incorrect here.
5fill in blank
hard

Fill all three blanks to define a Jenkins pipeline with a parameter and use it in a stage.

Jenkins
pipeline {
  agent any
  parameters {
    string(name: '[1]', defaultValue: 'world', description: 'Who to greet')
  }
  stages {
    stage('Greet') {
      steps {
        sh "echo Hello, [2]!"
      }
    }
  }
  environment {
    GREETING = '[3]'
  }
}
Drag options to blanks, or click blank then click option'
ANAME
B${params.NAME}
C"world"
DUSER
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter names or missing parameter syntax.