Complete the code to print the last build number in Jenkins pipeline.
echo "Last build number is: [1]"
In Jenkins pipeline, currentBuild.number gives the current build number.
Complete the code to archive the build logs as artifacts in Jenkins pipeline.
archiveArtifacts artifacts: '[1]', fingerprint: true
The pattern **/logs/*.log archives all log files inside any 'logs' folder.
Fix the error in the code to get the build duration in seconds.
def duration = currentBuild.[1] / 1000
currentBuild.durationInMillis holds the build duration in milliseconds.
Fill both blanks to filter build logs for errors and save them.
def errors = sh(script: 'grep [1] build.log', returnStdout: true).trim() writeFile file: 'errors.txt', text: [2]
Use grep "ERROR" to find error lines and save the variable errors to file.
Fill all three blanks to create a map of build numbers to their result status.
def buildResults = [[1]: [2] for build in currentBuild.rawBuild.project.builds if build.number > [3]]
Use build.number as key, build.result.toString() as value, and filter builds with number greater than 10.
