0
0
Jenkinsdevops~10 mins

Why jobs are Jenkins core unit - Test Your Understanding

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

Complete the code to define a Jenkins job that runs a shell command.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        [1] 'echo Hello, Jenkins!'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ash
Brun
Cexecute
Dcommand
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'execute' which are not valid Jenkins pipeline steps.
2fill in blank
medium

Complete the code to trigger a Jenkins job after another job finishes.

Jenkins
post {
  success {
    [1] 'DeployJob'
  }
}
Drag options to blanks, or click blank then click option'
AstartJob
Bbuild
CtriggerJob
DrunJob
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'triggerJob' which is not a valid pipeline step.
3fill in blank
hard

Fix the error in the Jenkins pipeline code to archive artifacts correctly.

Jenkins
steps {
  [1] artifacts: '**/*.jar', fingerprint: true
}
Drag options to blanks, or click blank then click option'
AstoreArtifacts
BarchiveFiles
CsaveArtifacts
DarchiveArtifacts
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'archiveFiles' which is not a valid Jenkins step.
4fill in blank
hard

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

Jenkins
stage('Deploy') {
  when {
    expression {
      BRANCH_NAME.[1]('master')
    }
  }
  steps {
    [2] 'deploy.sh'
  }
}
Drag options to blanks, or click blank then click option'
Aequals
Bsh
Cis
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'is' instead of 'equals' for branch condition.
5fill in blank
hard

Fill all three blanks to define a Jenkins pipeline that checks out code, builds, and archives artifacts.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        [1] scm
      }
    }
    stage('Build') {
      steps {
        [2] './build.sh'
      }
    }
    stage('Archive') {
      steps {
        [3] artifacts: '**/target/*.jar'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Acheckout
Bsh
CarchiveArtifacts
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' instead of 'sh' or 'archiveArtifacts'.