在EC2 Jenkins上编译项目的war文件

时间:2017-12-27 04:18:13

标签: maven amazon-web-services jenkins amazon-ec2

我的团队正在使用JavaEE和Angular 4,以及AWS EC2服务器,其上有Jenkins,并配置为在成功合并到master后,构建内容并生成具有构建状态的Slack通知。但是,当我负责管理它的人进入EC2服务器检查代码时,我找不到Jenkins应该在.jenkins或其他任何地方构建的WAR文件。如何让Jenkins构建一个.war文件,我可以访问它以启动我们的RESTful API服务?

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.zenith</groupId>
    <artifactId>SHOULDi-back</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>SHOULDi-back</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>


    <dependencies>

        <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
    <groupId>com.google.code.gson</groupId>
    <artifactId>gson</artifactId>
    <version>2.8.2</version>
</dependency>



        <dependency>
            <groupId>oracle</groupId>
            <artifactId>ojdbc7</artifactId>
            <version>12.1.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.bundles/jaxrs-ri -->
        <dependency>
            <groupId>org.glassfish.jersey.bundles</groupId>
            <artifactId>jaxrs-ri</artifactId>
            <version>2.25</version>
        </dependency>



        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-moxy -->
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-moxy</artifactId>
            <version>2.25</version>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.2.8.Final</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.4.0.Final</version>
        </dependency>






        <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>4.3.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>4.3.1.Final</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>SHOULDi-back</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
            </plugin>
        </plugins>
    </build>
</project>

2 个答案:

答案 0 :(得分:0)

根据您的Jenkins安装,.war可能位于/ var / lib / jenkins / workspace或其他目录中。请改为find /var/lib/jenkins/workspace -name *war*

要查找Jenkins主目录,如果不是,请登录服务器并运行sudo su - jenkins && pwd;如果失败,编辑/ etc / passwd并更改jenkins&#39;用户使用/ bin / bash而不是/ bin / false再试一次。

答案 1 :(得分:0)

这个问题似乎与我的pom.xml文件没什么关系,后者有这种麻烦的依赖:

<dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc7</artifactId>
        <version>12.1.0</version>
    </dependency>

,我必须废弃以使构建工作并生成.war文件。此外,我不得不调用顶级Maven目标作为构建步骤。在那里,我指定了pom.xml的路径。完成后,构建成功并生成.war文件。至于.war文件是否真的有用,那么,这是另一个话题。