How to change JAR build path in Jenkins?

Viewed 3500

I am building a Java project via Jenkins. The JAR is being created (after I execute maven clean install in Jenkins) in C:\Windows\System32\config\systemprofile.m2\repository\com\other folders.

Is there any way to change this path? I want to sent the JAR to a VM via SSH. However, I am not able to access this folder since this is system directory.

Thank you.

3 Answers

For some reason, your Jenkins uses this directory as local Maven repository. I would define a different local repository in Jenkins or in the settings.xml. It is also important that you make sure that no two running builds use the same local repository at the same time because local repositories cannot be used concurrently.

If you are using maven to build, add the below to your pom.xml

<build>
  <plugins>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <version>2.3.1</version>
  <configuration>
    <outputDirectory>your custom location</outputDirectory>
  </configuration>
</plugin>
</plugins>
</build>

By default, maven should create your build artifacts (including the JAR file) in target directory next to your pom.xml.

You can change this behavior in pom.xml by specifying the build directory:

<build>
   <directory>/some/other/dir</directory>
</build>

The directory you are referring to is your local maven repository, which contains all JAR files maven is working with. You can read more about local maven repository here.

Related