0
votes

I have a Spring boot application which I want to deploy to Google App Engine via gitlab CI. The build is failing with the following error :

ERROR: (gcloud.app.deploy) To use the local staging for java, a Java 7+ JRE must be installed and on your system PATH

Below is gitlab-ci.yml file which needs to be modified to include JRE installation. I have tried almost all ways available over web including using apt-get package, Also installing app-engine-java using gcloud but non prints java -verison. Can someone please modify this ci file for installing jre 7+ dependencies.

        ```
        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: [[email protected]]
        $ 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
        ```
1
Formatting is not proper makes reading and uderstanding difficult. - Driss Bounouar

1 Answers

0
votes

You can go here for more information on how to to add openjdk-8 to the Docker image. This SO post contains an answer with additional links on how to setup the missing java jdk files.