【问题标题】:How to deploy a Java web application with Travis CI to an OpenShift WildFly server?如何使用 Travis CI 将 Java Web 应用程序部署到 OpenShift WildFly 服务器?
【发布时间】:2015-02-20 21:58:49
【问题描述】:

我想使用 Travis CI 从 GitHub 将我的 Web 应用程序部署到 OpenShift 上的 WildFly 应用程序服务器。

我按照 How to Build and Deploy OpenShift Java Projects using Travis CI 教程进行操作,但我的 Java EE 7 Web 应用程序中的 index.html 页面没有显示。我得到的是 OpenShift 的默认页面,而不是 index.html 页面,上面写着:“欢迎使用 OpenShift 上的 WildFly 8 应用程序”。

我必须做什么才能显示我的 web 应用程序?

这是我的 Travis CI 控制台日志的最后几行:

remote: [WARNING] The requested profile "openshift" could not be activated because it does not exist.
remote: Preparing build for deployment
remote: Deployment id is 20db7c5e
remote: Activating deployment
remote: HAProxy already running
remote: HAProxy instance is started
remote: Deploying WildFly
remote: ls: cannot access /var/lib/openshift/54e7963efcf933b7e2000037/app-root/runtime/repo//deployments: No such file or directory
remote: Starting wildfly cart
remote: Found 127.9.239.1:8080 listening port
remote: Found 127.9.239.1:9990 listening port
remote: /var/lib/openshift/54e7963efcf933b7e2000037/wildfly/standalone/deployments /var/lib/openshift/54e7963efcf933b7e2000037/wildfly
remote: /var/lib/openshift/54e7963efcf933b7e2000037/wildfly
remote: CLIENT_MESSAGE: Artifacts deployed: ./ROOT.war
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success

你可以在这里查看我的 webapp 代码:https://github.com/welovecoding/javeasy

部署可见:http://www.javeasy.com/

【问题讨论】:

    标签: continuous-integration openshift travis-ci java-ee-7 wildfly-8


    【解决方案1】:

    我发现了问题。我没有在我的pom.xml 中定义openshift 配置文件。声明 openshift 配置文件解决了我的问题。

    这是我的 pom.xml 作为参考:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
    
      <groupId>com.javeasy</groupId>
      <artifactId>javeasy</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>war</packaging>
    
      <name>javeasy</name>
    
      <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.executable>${env.OPENSHIFT_WILDFLY_DIR}usr/lib/jvm/jdk1.8.0_05/bin/javac</maven.compiler.executable>
        <maven.compiler.fork>true</maven.compiler.fork>
      </properties>
    
      <dependencies>
        <dependency>
          <groupId>javax</groupId>
          <artifactId>javaee-api</artifactId>
          <version>7.0</version>
          <scope>provided</scope>
        </dependency>
      </dependencies>
    
      <profiles>
        <profile>
          <!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
          <!-- Use this profile for any OpenShift specific customization your app will need. -->
          <!-- By default that is to put the resulting archive into the 'deployments' folder. -->
          <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
          <id>openshift</id>
          <build>
            <finalName>jbosswildfly</finalName>
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                  <failOnMissingWebXml>false</failOnMissingWebXml>
                  <outputDirectory>deployments</outputDirectory>
                  <warName>ROOT</warName>
                </configuration>
              </plugin>
            </plugins>
          </build>
        </profile>
      </profiles>
    </project>
    

    这是我的 .travis.yml

    # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
    sudo: false
    
    # http://docs.travis-ci.com/user/languages/java/
    language: java
    jdk:
      - oraclejdk8
    
    # http://docs.travis-ci.com/user/deployment/openshift/
    deploy:
      provider: openshift
      user: me@mail.com
      password:
        secure: ...=
      app: jbosswildfly
      domain: welovecoding
      on:
        repo: welovecoding/javeasy
    

    申请网址为:jbosswildfly-welovecoding.rhcloud.com

    GitHub 仓库是:https://github.com/welovecoding/javeasy

    .travis.yml 已使用以下命令与 Travis command line client 创建:

    travis login
    travis setup openshift -r welovecoding/javeasy
    

    参数-r定义了GitHub存储库。

    【讨论】:

      猜你喜欢
      • 2019-01-10
      • 1970-01-01
      • 1970-01-01
      • 2018-09-08
      • 2020-09-17
      • 2019-01-03
      • 2015-05-16
      • 2020-11-09
      • 2017-03-14
      相关资源
      最近更新 更多