0
0
Jenkinsdevops~5 mins

currentBuild variables in Jenkins - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is currentBuild in Jenkins pipelines?

currentBuild is a special variable in Jenkins pipelines that holds information about the current running build, such as its status, duration, and result.

Click to reveal answer
beginner
How can you get the result status of the current build using currentBuild?

You can access the build result status with currentBuild.result. It returns values like SUCCESS, FAILURE, or UNSTABLE.

Click to reveal answer
beginner
What does currentBuild.duration represent?

currentBuild.duration gives the time in milliseconds that the build has taken so far or took when finished.

Click to reveal answer
intermediate
How to mark the current build as failed using currentBuild?

Set currentBuild.result = 'FAILURE' in your pipeline script to mark the build as failed.

Click to reveal answer
intermediate
Can currentBuild be used to add a description to the build? How?

Yes, you can add a description by setting currentBuild.description = 'Your description here'.

Click to reveal answer
What type of information does currentBuild provide in Jenkins?
AList of all jobs
BDetails about the current running build
CUser credentials
DInformation about the Jenkins server
How do you check if the current build succeeded using currentBuild?
ACheck if <code>currentBuild.status == 'DONE'</code>
BCheck if <code>currentBuild.finished == true</code>
CCheck if <code>currentBuild.state == 'OK'</code>
DCheck if <code>currentBuild.result == 'SUCCESS'</code>
Which currentBuild property gives the build duration?
A<code>currentBuild.duration</code>
B<code>currentBuild.time</code>
C<code>currentBuild.length</code>
D<code>currentBuild.elapsed</code>
How can you mark a build as unstable using currentBuild?
A<code>currentBuild.state = 'UNSTABLE'</code>
B<code>currentBuild.status = 'UNSTABLE'</code>
C<code>currentBuild.result = 'UNSTABLE'</code>
D<code>currentBuild.finished = 'UNSTABLE'</code>
Which of these is NOT a valid use of currentBuild?
ARestarting Jenkins server
BChanging build result
CAccessing build duration
DSetting build description
Explain what currentBuild is and list three useful properties you can access or modify.
Think about what info about the running build you might want to check or change.
You got /3 concepts.
    Describe how you would use currentBuild to mark a Jenkins pipeline build as failed and add a description explaining why.
    Consider how to communicate failure reasons in the build UI.
    You got /3 concepts.