I define a custom tool in Jenkins and I would like to run it during a build. In "https://wiki.jenkins.io/display/JENKINS/Custom+Tools+Plugin" I see the following : "Then, you just need to add the tool requirement to your job's Build Environment" but I cannot find such an option anywhere. Where can I find it? Or is there another way to run the installation of the custom tool?
Jenkins : How to add custom tool to my job's build environment
12.1k Views Asked by Ivajlo Iliev At
3
There are 3 best solutions below
4
On
In your project configuration (/job/<your-project>/configure), in the Build Environment area, there's an option to "Install custom tools". Check this and you can choose from the tools you've configured in the Global Tool Configuration (/configureTools/), and if you specified a script it will be run at the start of your build to install the tool.
In this example I've chosen to add the clojure tool i've configured to the build.
2
On
If you are using scripted pipelines you can add a tool using the 'tool' command. The following example is to add a custom tool to a scripted pipeline. The tool must already be defined through the custom-tool-plugin in your global jenkins administration.
#!/usr/bin/env groovy
node('windows') {
stage ('prepare env ') {
withEnv(["MY_TOOL_DIR=${tool name: 'my_tool', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool'}"]){
echo "Path to my_tool\"${MY_TOOL_DIR}\""
bat( script: '@"%MY_TOOL_DIR%\\my_tool.exe",
returnStdout: true)
}
}
}

Is this a Pipeline? If it is, you can include it in the pipeline file under 'environment', prior to the stages, like so: