簡體   English   中英

如何更改 Jenkins 中的 JAR 構建路徑?

[英]How to change JAR build path in Jenkins?

我正在通過 Jenkins 構建一個 Java 項目。 JAR 正在 C:\Windows\System32\config\systemprofile.m2\re

有什么辦法可以改變這條路嗎? 我想通過 SSH 將 JAR 發送到 VM。 但是,我無法訪問此文件夾,因為這是系統目錄。

謝謝你。

如果您使用 maven 構建,請將以下內容添加到您的 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>

默認情況下, maven 應該在 pom.xml 旁邊的target目錄中創建構建工件(包括pom.xml文件)。

您可以通過指定構建目錄在pom.xml中更改此行為:

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

您所指的目錄是您的本地 maven 存儲庫,其中包含 maven 正在使用的所有 JAR 文件。 您可以在此處閱讀有關本地 maven 存儲庫的更多信息。

出於某種原因,您的 Jenkins 將此目錄用作本地 Maven 存儲庫。 我會在 Jenkins 或settings.xml中定義一個不同的本地存儲庫。 確保沒有兩個正在運行的構建同時使用同一個本地存儲庫也很重要,因為本地存儲庫不能同時使用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM