Ivajlo Iliev
Ivajlo Iliev

Reputation: 463

Jenkins : How to add custom tool to my job's build environment

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?

Upvotes: 4

Views: 13555

Answers (3)

Markus Hofsetter
Markus Hofsetter

Reputation: 1

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)
        }
    }
}

Upvotes: 0

Conan
Conan

Reputation: 2358

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.

enter image description here

In this example I've chosen to add the clojure tool i've configured to the build.

Upvotes: -1

Sean C
Sean C

Reputation: 83

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

pipeline {
  agent any
  options {
    timestamps()
  }
  environment {
      TOOL = tool name: '<tool>', type:     'com.cloudbees.jenkins.plugins.customtools.CustomTool'
  }
  stages {
...
}

Upvotes: 3

Related Questions