18. Tool

18.1. Examples

18.1.1. Example 1

Listing 59. Tool
/*
* Requirements
* Do not work with docker
* If you put invalid, it will list valid
* Automaticly installs requirements
*/

pipeline {
    agent any

    tools {
        maven "apache-maven-3.1.0"
        jdk "default"
    }

    stages {
        stage('Test') {

        }
    }
}

18.1.2. Example 2

Listing 60. Tool
pipeline {
    agent any

    stages {
        stage("simple") {
            steps {

                // withMaven will discover the generated Maven artifacts, JUnit Surefire & FailSafe & FindBugs reports...
                // Maven installation declared in the Jenkins "Global Tool Configuration"
                withMaven(maven: 'mvn_3.0.4') {
                      sh '/usr/bin/mvn clean install'
                 }
            }
        }
    }
}