Resolution
Option 1: Passing toolchain as parameter
Advantage: In an isolated environment you don’t have conflicts
Follow these steps to use Maven Toolchain in Jenkins and integrate it with your goals settings:
1. Install the Config Provider Plugin.
2. Go to "Manage Jenkins -> Managed files".
3. Click on "Add a new config".
4. Click on "Maven toolchain" and click submit.
5. Paste there your toolchain file and save.
6. Go to your Maven project job and in the "Build Environment" section, click on "Provided configuration files", select the toolchain file created and choose a Variable name.
7. Now you can use in your job the variable created.
For the example provided you only have to add ` -t $TOOLCHAIN` in your Goal of your maven job
You need to have one or several JDK installed on the agent and you have to hardcode their paths in the toolchain (You could have some problem using the path of JDKs installed with the default JDK Installer or with the Custom tools installer) |
Option 2: Placing the toolchain under $HOME/.m2/toolchain.xml
Same as Option 1
for steps from 1 to 5 and then:
6. Go to your Maven project job and in the "Build Environment" section, click on "Provided configuration files", select the toolchain file created and choose a Target a fill it with $HOME/.m2/toolchain.xml
(its default location)