【问题标题】:How to Install Maven in AWS CodeBuild Standard Linux 2.0 (Ubuntu 18.0)如何在 AWS CodeBuild Standard Linux 2.0 (Ubuntu 18.0) 中安装 Maven
【发布时间】:2020-01-22 11:19:38
【问题描述】:

我正在尝试使用 AWS Codebuild 构建我的项目。下面是我的 buildspce.yml。我的源代码在 s3 存储桶中,文件类型是 zip。

 version: 0.2
phases:
  install:
    runtime-versions:
       java: openjdk8
    commands:
        - apt-get update -y
        - apt-get install -y maven
  pre_build:
    commands:
       - java -version
       - mvn -version 
      # - command
  build:
    commands:
       - echo Entered the build phase...
       - echo Build started on `date`
       - mvn package -Dmaven.test.failure.ignore=true
      # - command
    finally:
      - echo This always runs even if the install command fails
  #post_build:
    #commands:
      # - command
      # - command
#reports:
  #report-name-or-arn:
    #files:
      # - location
      # - location
    #base-directory: location
    #discard-paths: yes
    #file-format: JunitXml | CucumberJson
#artifacts:
  #files:
    # - location
    # - location
  #name: $(date +%Y-%m-%d)
  #discard-paths: yes
  #base-directory: location
#cache:
  #paths:
    # - paths

我在安装阶段遇到COMMAND_EXECUTION_ERROR: Error while executing command: apt-get install -y maven. Reason: exit status 100 错误。即使我从安装阶段删除了 maven 并且只添加了mvn package,那么exit code 1 也会出现错误。

【问题讨论】:

    标签: aws-codepipeline aws-codebuild


    【解决方案1】:

    Maven 已经安装在 java: openjdk8 中,可以在此处确认 [1]。

    做了一个快速测试:

    version: 0.2
    
    phases:
      install:
        runtime-versions:
          java: openjdk8
    
      build:
        commands:
          - mvn -v
    

    构建日志:

    [Container] 2020/01/23 10:51:01 Running command mvn -v
    Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)
    Maven home: /opt/maven
    Java version: 1.8.0_222, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
    Default locale: en, platform encoding: UTF-8
    OS name: "linux", version: "4.14.152-98.182.amzn1.x86_64", arch: "amd64", family: "unix"
    

    [1]https://github.com/aws/aws-codebuild-docker-images/blob/master/ubuntu/standard/2.0/Dockerfile

    【讨论】:

      猜你喜欢
      • 2020-05-06
      • 1970-01-01
      • 1970-01-01
      • 2013-01-25
      • 1970-01-01
      • 2014-01-14
      • 2013-12-02
      • 2015-07-14
      • 2017-08-28
      相关资源
      最近更新 更多