Bluemix devops构建管道支持java 8应用程序吗?

时间:2015-05-23 22:40:47

标签: java-8 ibm-cloud ibm-jazz

鉴于支持java 8的Bluemix announcement。 我需要做什么才能在IBM Bluesmix构建管道(jazzhub构建和部署)中编译我的Java 8应用程序。

我已经设置了java8环境变量并使用以下内容重新启动了应用程序:

cf set-env <myApp> JBP_CONFIG_IBMJDK "version: 1.8.+"
cf restage <myApp>

我使用的特定“构建器类型”是“Maven”,我收到的失败是围绕java8中的新日期和时间类。

[ERROR] <...>/services/TestHelperService.java:[3,17] package java.time does not exist
[ERROR] <...>/services/TestHelperService.java:[37,17] cannot find symbol
[ERROR] symbol:   class LocalDateTime
[ERROR] location: class <...>.services.TestHelperService

4 个答案:

答案 0 :(得分:10)

要使用Java 8,您需要在build shell命令中更改JAVA_HOME环境变量:

export JAVA_HOME=~/java8

例如:

#!/bin/bash
#export JAVA_HOME=~/java8 - Bluemix have changed the java8 location
export JAVA_HOME=/opt/IBM/java8
mvn -B package

答案 1 :(得分:1)

我还想在Bluemix Jazz构建管道中使用Java8。只是改变$JAVA_HOME对我不起作用。我还必须更新$PATH

export JAVA_HOME=/opt/IBM/java8
export PATH=$JAVA_HOME/bin:$PATH

之后,maven在java8上运行。

答案 2 :(得分:0)

嗨,这个解决方案对我来说不起作用,这是我的构建脚本

#!/bin/bash
echo "Java Home before $JAVA_HOME"
export JAVA_HOME=~/java8
echo "Java Home after $JAVA_HOME"
#mvn -B package -DskipTests
#mvn -B package

这是控制台输出,你可以看到在“export”命令后没有修改JAVA_HOME。

Checking out Revision 86514c6dc277b6903fcd6f51ca7c97ea733b1d42 (detached)
[ba6eba91-33a3-4b67-8efd-48962cf063ba] $ /bin/bash /tmp/hudson7007424628517212775.sh
Java Home before /home/jenkins/java
Java Home after /home/jenkins/java
Base artifact directory /home/jenkins/workspace/e92a4db8-6702-d006-0cdc-2a827a4e78a5/ba6eba91-33a3-4b67-8efd-48962cf063ba/target does not exist or is not a valid directory.
[xUnit] [INFO] - Starting to record.
[xUnit] [INFO] - Processing JUnit
[xUnit] [INFO] - [JUnit] - No test report file(s) were found with the pattern 'target/surefire-reports/TEST-*.xml' relative to '/home/jenkins/workspace/e92a4db8-6702-d006-0cdc-2a827a4e78a5/ba6eba91-33a3-4b67-8efd-48962cf063ba' for the testing framework 'JUnit'.  Did you enter a pattern relative to the correct directory?  Did you generate the result report(s) for 'JUnit'?
[xUnit] [ERROR] - No test reports found for the metric 'JUnit' with the resolved pattern 'target/surefire-reports/TEST-*.xml'. Configuration error?.
[xUnit] [INFO] - There are errors when processing test results.
[xUnit] [INFO] - Skipping tests recording.
Finished: SUCCESS

答案 3 :(得分:0)

我可以确认在构建脚本中将JAVA_HOME设置为/ opt / IBM / java8确实有效(在2016-05-04上试用):

#!/bin/bash
 echo "Java home before: $JAVA_HOME"
 export JAVA_HOME=/opt/IBM/java8
 echo "Java home after: $JAVA_HOME"
 mvn -B package

这导致输出:

Java home before: /opt/IBM/java
Java home after: /opt/IBM/java8

如前所述,部署阶段必须将JBP_CONFIG_IBMJDK设置为&#34;版本:1.8。+&#34; (cf set-env myApp JBP_CONFIG_IBMJDK "version: 1.8.+"或env中的行:manifest.yml的部分)或者(我做的是)你需要在manifest.yml中定义buildpack: java_buildpack。自2015年5月起,java_buildpack使用JDK8。

最后要注意的是在pom.xml中更改maven-compiler-plugin的源版本 - 当然 - 但这不是特定于Bluemix的。

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>(whatever version is current)</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>