How to config a Maven Toolchain

Article ID:115003910392
1 minute readKnowledge base

Issue

How to config a Maven Toolchain and how to integrate that with your goal settings

Environment

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".

Manage Files Option 3. Click on "Add a new config".

Add a new config option

4. Click on "Maven toolchain" and click submit.

Maven Toolchain option 5. Paste there your toolchain file and save.

Edit configuration file

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.

Config Toolchain variable

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)

Config Toolchain variable