13. Option

13.1. Examples

Listing 54. Option
pipeline {
    agent any

    options {
        timeout(time: 1, unit: 'HOURS')
        // Prepend all console output generated by the Pipeline run with the time at which the line was emitted
        timestamps()

        /*
         * Parameters for logRotator
         * - daysToKeepStr: history is only kept up to this days.
         * - numToKeepStr: only this number of build logs are kept.
         * - artifactDaysToKeepStr: artifacts are only kept up to this days.
         * - artifactNumToKeepStr: only this number of builds have their artifacts kept.
         */
        buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30'))
    }

    stages {
        stage('Test') {
            steps {
                sh '/bin/echo Testing...'
            }
        }
    }
}