如何在 AWS CodeBuild Standard Linux 2.0 (Ubuntu 18.0) 中安装 Maven



我正在尝试使用AWSCodebuild构建我的项目。下面是我的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错误。

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

最新更新