0
0
Jenkinsdevops~10 mins

CI/CD pipeline mental model in 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 define a Jenkins pipeline that starts with the 'Build' stage.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        [1] 'echo Building the project'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ash
Bscript
Cinput
Dstage
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'script' instead of 'sh' to run shell commands.
2fill in blank
medium

Complete the code to add a 'Test' stage after the 'Build' stage in the Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        sh 'echo Building the project'
      }
    }
    stage('[1]') {
      steps {
        sh 'echo Running tests'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
ADeploy
BPackage
CBuild
DTest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Deploy' or 'Package' instead of 'Test' for the testing stage.
3fill in blank
hard

Fix the error in the Jenkins pipeline code by completing the missing keyword for parallel stages.

Jenkins
pipeline {
  agent any
  stages {
    stage('Build and Test') {
      [1] {
        stage('Build') {
          steps {
            sh 'echo Building'
          }
        }
        stage('Test') {
          steps {
            sh 'echo Testing'
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aparallel
Bsteps
Cscript
Dagent
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'steps' or 'script' instead of 'parallel' for concurrent stages.
4fill in blank
hard

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

Jenkins
pipeline {
  agent any
  stages {
    stage('Deploy') {
      when {
        [1] '[2]'
      }
      steps {
        sh 'echo Deploying to production'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Abranch
Benvironment
Cmain
Dfeature
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'environment' instead of 'branch' in the when condition.
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline that defines an environment variable and uses it in a shell command.

Jenkins
pipeline {
  agent any
  environment {
    [1] = '[2]'
  }
  stages {
    stage('Print Env') {
      steps {
        sh 'echo [3]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
AGREETING
BHello, World!
C$GREETING
DMESSAGE
Attempts:
3 left
💡 Hint
Common Mistakes
Using the variable name without the $ sign in the shell command.