gpt4 book ai didi

java - 使用 Gitlab CI 将 Spring Boot 应用程序部署到 Google App Engine?

转载 作者:行者123 更新时间:2023-12-02 00:32:25 25 4
gpt4 key购买 nike

我有一个 Spring boot 应用程序,我想通过 gitlab CI 部署到 Google App Engine。构建失败并出现以下错误:

错误:(gcloud.app.deploy) 要使用 java 的本地暂存,必须安装 Java 7+ JRE 并位于您的系统路径

下面是 gitlab-ci.yml 文件,需要修改该文件以包含 JRE 安装。我已经尝试了几乎所有通过网络可用的方法,包括使用 apt-get 包,还使用 ​​gcloud 安装 app-engine-java 但不打印 java -verison。有人可以修改这个 ci 文件来安装 jre 7+ 依赖项吗?

        ```
image: google/cloud-sdk:alpine
deploy_production:
stage: deploy
environment: Production
only:
- master
script:
- echo $DEPLOY_KEY_FILE_PRODUCTION > /tmp/$CI_PIPELINE_ID.json
- gcloud -q components install app-engine-java
- gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
- gcloud --quiet --project $PROJECT_ID_PRODUCTION --verbosity debug app deploy src/main/webapp/WEB-INF/appengine-web.xml```

Logs:
```Pulling docker image google/cloud-sdk:alpine ...
Using docker image sha256:6a09bced8955f4d2969e7d33b0acf31f83930933b0f775ad5768f3dc8496d99a for google/cloud-sdk:alpine ...
Running on runner-F7vG1_9e-project-1361-concurrent-0 via runner-f7vg19e-docker-auto-scale-1568834560-aeda2a66...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/sre/jira-servicenow-integration/.git/
Created fresh repository.
From https://gitlab.lblw.ca/sre/jira-servicenow-integration
* [new branch] master -> origin/master
Checking out fe1260a3 as master...

Skipping Git submodules setup
$ docker run google/cloud-sdk:alpine sh -c 'gcloud auth print-access-token' | docker login --password-stdin -u oauth2accesstoken https://gcr.io || true
/bin/bash: line 86: docker: command not found
/bin/bash: line 86: docker: command not found
$ echo $DEPLOY_KEY_FILE_PRODUCTION > /tmp/$CI_PIPELINE_ID.json
$ gcloud -q components install app-engine-java


Your current Cloud SDK version is: 262.0.0
Installing components from version: 262.0.0

+---------------------------------------------------+
| These components will be installed. |
+------------------------------+---------+----------+
| Name | Version | Size |
+------------------------------+---------+----------+
| Cloud Datastore Emulator | 2.1.0 | 18.4 MiB |
| gRPC python library | | |
| gRPC python library | 1.20.0 | 2.1 MiB |
| gcloud app Java Extensions | 1.9.76 | 85.9 MiB |
| gcloud app Python Extensions | 1.9.86 | 6.0 MiB |
+------------------------------+---------+----------+

For the latest full release notes, please visit:
https://cloud.google.com/sdk/release_notes

#============================================================#
#= Creating update staging area =#
#============================================================#
#= Installing: Cloud Datastore Emulator =#
#============================================================#
#= Installing: gRPC python library =#
#============================================================#
#= Installing: gRPC python library =#
#============================================================#
#= Installing: gcloud app Java Extensions =#
#============================================================#
#= Installing: gcloud app Python Extensions =#
#============================================================#
#= Creating backup and activating new installation =#
#============================================================#

Performing post processing steps...
..........................................................done.

Update done!

$ gcloud auth activate-service-account --key-file /tmp/$CI_PIPELINE_ID.json
Activated service account credentials for: [playground-kg@appspot.gserviceaccount.com]
$ gcloud --quiet --project $PROJECT_ID_PRODUCTION --verbosity debug app deploy src/main/webapp/WEB-INF/appengine-web.xml
DEBUG: Running [gcloud.app.deploy] with arguments: [--project: "playground-kg", --quiet: "True", --verbosity: "debug", DEPLOYABLES:1: "[u'src/main/webapp/WEB-INF/appengine-web.xml']"]
DEBUG: (gcloud.app.deploy) To use the local staging for java, a Java 7+ JRE must be installed and on your system PATH
Traceback (most recent call last):
File "/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 983, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 784, in Run
resources = command_instance.Run(args)
File "/google-cloud-sdk/lib/surface/app/deploy.py", line 90, in Run
parallel_build=False)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 573, in RunDeploy
args.deployables, stager, deployables.GetPathMatchers())
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deployables.py", line 334, in GetDeployables
service = Service.FromPath(path, stager, path_matchers)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deployables.py", line 102, in FromPath
service = matcher(path, stager)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deployables.py", line 175, in AppengineWebMatcher
staging_dir = stager.Stage(descriptor, app_dir, 'java-xml', env.STANDARD)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/staging.py", line 387, in Stage
return command.Run(self.staging_area, descriptor, app_dir)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/staging.py", line 171, in Run
args = self.GetArgs(descriptor, app_dir, staging_dir)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/staging.py", line 251, in GetArgs
return self._mapper(self.GetPath(), descriptor, app_dir, staging_dir)
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/staging.py", line 107, in _JavaStagingMapper
java_bin = java.RequireJavaInstalled('local staging for java')
File "/google-cloud-sdk/lib/googlecloudsdk/command_lib/util/java.py", line 54, in RequireJavaInstalled
v=min_version))
JavaError: To use the local staging for java, a Java 7+ JRE must be installed and on your system PATH
ERROR: (gcloud.app.deploy) To use the local staging for java, a Java 7+ JRE must be installed and on your system PATH
ERROR: Job failed: exit code 1
```

最佳答案

你可以去here有关如何将 openjdk-8 添加到 Docker 镜像的更多信息。这个SO帖子包含一个答案,其中包含有关如何设置丢失的 java jdk 文件的附加链接。

关于java - 使用 Gitlab CI 将 Spring Boot 应用程序部署到 Google App Engine?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58001974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com