Как заставить Maven с Дженкинсом использовать конкретные JDK? - PullRequest
0 голосов
/ 27 февраля 2019

У меня на компьютере jdk 7 и 8, JAVA_HOME указывает на java 7, а Jenkins использует java 8. Я создал проект maven и пытаюсь построить его на jenkins с использованием java 8, но получаю следующую ошибку:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven-demo: Compilation failure -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

в pom.xml я добавил следующее:

<properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>

и

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <verbose>true</verbose>
          <fork>true</fork>
           <source>1.8</source>
           <target>1.8</target>
          <executable>path/to/jdk/bin/javac</executable>
        </configuration>
      </plugin>
    </plugins>
</build>

, но я все еще получаю ту же ошибку с любым из методов 2 выше.

Как я могу обновить его, чтобы maven использовал Java 8?

1 Ответ

0 голосов
/ 27 февраля 2019

Вы должны настроить свой Jenkins в разделе Global Tool Configuration с помощью Name и JAVA_HOME ваших разных jdks.http://path -в-ваш-Jenkins: 8080 / configureTools / .После этого вы можете выбрать JDK в конфигурации вашего проекта http://path -to-your-jenkins: 8080 / job / yourJob / configure .Во вкладке General в поле JDK.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...