无法在Google Cloud Build中构建罐子

发布于 2025-01-22 15:29:52 字数 8256 浏览 3 评论 0原文

我是Google Cloud的新手,我正在与Maven一起构建一个应用程序。在我的Maven存储库中,我有LIB文件夹,其中有Didisoft Jar文件。

我已经在Maven中添加了插件,以将它们添加到ClassPath中。在本地,我能够构建项目,但是当在云构建上执行相同的步骤时,“ MVN Clean Install”会失败。

“所有三个依赖项的插件”

“云构建中的错误”

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>ingka</groupId>
    <artifactId>hrb2b-decom</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>hrb2b-decom</name>
    <description>hrb2b decommissioning project</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.cloud</groupId>
                <artifactId>libraries-bom</artifactId>
                <version>24.4.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
            <version>1.2.8.RELEASE</version>
        </dependency>
        <!-- <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency> --> 
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-storage</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.didisoft</groupId>
            <artifactId>pgplib</artifactId>
            <version>3.2.3</version>
        </dependency>

        <dependency>
            <groupId>com.didisoft</groupId>
            <artifactId>bcpg-lw-jdk15on</artifactId>
            <version>1.70</version>
        </dependency>

        <dependency>
            <groupId>com.didisoft</groupId>
            <artifactId>bcprov-lw-jdk15on</artifactId>
            <version>1.70</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install-external-main</id>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/lib/pgplib-3.2.3.jar</file>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>com.didisoft</groupId>
                            <artifactId>pgplib</artifactId>
                            <version>3.2.3</version>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>install-external-lib1</id>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/lib/bcpg-lw-jdk15on-1.70.jar</file>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>com.didisoft</groupId>
                            <artifactId>bcpg-lw-jdk15on</artifactId>
                            <version>1.70</version>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>install-external-lib2</id>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/lib/bcprov-lw-jdk15on-1.70.jar</file>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>com.didisoft</groupId>
                            <artifactId>bcprov-lw-jdk15on</artifactId>
                            <version>1.70</version>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

---

Cloudbuild.yaml

 steps:
 - name: maven:3-jdk-8
   entrypoint: mvn
   args: ['clean','install']
 - name: gcr.io/cloud-builders/docker
   args: ['build', '-t', 'gcr.io/<projectId>/first-image', '--build-arg=JAR_FILE=target/gcpbuild-0.0.1-SNAPSHOT.jar', '.']
 - name: 'gcr.io/cloud-builders/docker'
   args: ['push', 'gcr.io/<projectId>/first-image']
 images: ['gcr.io/<projectId>/first-image']

I am new to google cloud, I am building an application with maven. In my maven repository I have lib folder where I have didisoft jar files.

I have added the plugins in maven to add them in the classpath. Locally, I am able to build the project but when same steps are executing on cloud build, the 'mvn clean install' fails.

Dependencies

Plugins for all three dependencies

Error in the cloud build

POM --

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>ingka</groupId>
    <artifactId>hrb2b-decom</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>hrb2b-decom</name>
    <description>hrb2b decommissioning project</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.google.cloud</groupId>
                <artifactId>libraries-bom</artifactId>
                <version>24.4.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
            <version>1.2.8.RELEASE</version>
        </dependency>
        <!-- <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency> --> 
        <dependency>
            <groupId>com.google.cloud</groupId>
            <artifactId>google-cloud-storage</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-sleuth</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.didisoft</groupId>
            <artifactId>pgplib</artifactId>
            <version>3.2.3</version>
        </dependency>

        <dependency>
            <groupId>com.didisoft</groupId>
            <artifactId>bcpg-lw-jdk15on</artifactId>
            <version>1.70</version>
        </dependency>

        <dependency>
            <groupId>com.didisoft</groupId>
            <artifactId>bcprov-lw-jdk15on</artifactId>
            <version>1.70</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <executions>
                    <execution>
                        <id>install-external-main</id>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/lib/pgplib-3.2.3.jar</file>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>com.didisoft</groupId>
                            <artifactId>pgplib</artifactId>
                            <version>3.2.3</version>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>install-external-lib1</id>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/lib/bcpg-lw-jdk15on-1.70.jar</file>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>com.didisoft</groupId>
                            <artifactId>bcpg-lw-jdk15on</artifactId>
                            <version>1.70</version>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>install-external-lib2</id>
                        <phase>clean</phase>
                        <configuration>
                            <file>${basedir}/lib/bcprov-lw-jdk15on-1.70.jar</file>
                            <repositoryLayout>default</repositoryLayout>
                            <groupId>com.didisoft</groupId>
                            <artifactId>bcprov-lw-jdk15on</artifactId>
                            <version>1.70</version>
                            <packaging>jar</packaging>
                            <generatePom>true</generatePom>
                        </configuration>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

---

Cloudbuild.yaml

 steps:
 - name: maven:3-jdk-8
   entrypoint: mvn
   args: ['clean','install']
 - name: gcr.io/cloud-builders/docker
   args: ['build', '-t', 'gcr.io/<projectId>/first-image', '--build-arg=JAR_FILE=target/gcpbuild-0.0.1-SNAPSHOT.jar', '.']
 - name: 'gcr.io/cloud-builders/docker'
   args: ['push', 'gcr.io/<projectId>/first-image']
 images: ['gcr.io/<projectId>/first-image']

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆凄美了谁 2025-01-29 15:29:52

看来您在设置和POM文件上丢失了东西,您可以找到有关如何做的说明在这里

It looks like you are missing things on the settings and pom files, you can find the instructions of how to do it here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文