0
0
Jenkinsdevops~10 mins

Declarative pipeline syntax 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 start a declarative Jenkins pipeline.

Jenkins
pipeline {
    agent [1]
    stages {
        stage('Build') {
            steps {
                echo 'Building...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Adocker
Bnode
Cmaster
Dany
Attempts:
3 left
💡 Hint
Common Mistakes
Using node which is scripted pipeline syntax.
Using master which is deprecated.
Using docker without proper configuration.
2fill in blank
medium

Complete the code to define a stage named 'Test'.

Jenkins
pipeline {
    agent any
    stages {
        stage([1]) {
            steps {
                echo 'Testing...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
A'Deploy'
B'Build'
C'Test'
D'Verify'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the stage name.
Using the wrong stage name.
3fill in blank
hard

Fix the error in the steps block to print 'Deploying...'.

Jenkins
pipeline {
    agent any
    stages {
        stage('Deploy') {
            steps {
                [1] 'Deploying...'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Awrite
Becho
Cprintln
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using print which is not recognized in Jenkins pipelines.
Using println which is not valid here.
4fill in blank
hard

Fill both blanks to add a post action that always runs and echoes 'Cleaning up'.

Jenkins
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                echo 'Building...'
            }
        }
    }
    post {
        [1] {
            steps {
                [2] 'Cleaning up'
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
Aalways
Becho
Csuccess
Dfailure
Attempts:
3 left
💡 Hint
Common Mistakes
Using success or failure instead of always.
Using print instead of echo.
5fill in blank
hard

Fill all three blanks to create an environment variable named 'VERSION' with value '1.0' and echo it in the build stage.

Jenkins
pipeline {
    agent any
    environment {
        [1] = [2]
    }
    stages {
        stage('Build') {
            steps {
                [3] "Version is $VERSION"
            }
        }
    }
}
Drag options to blanks, or click blank then click option'
AVERSION
B"1.0"
Cecho
Dversion
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase variable names.
Not quoting the value string.
Using print instead of echo.