aws代码构建在构建步骤失败

时间:2017-11-16 14:53:00

标签: amazon-web-services amazon-ec2 aws-codepipeline

嗨我几个月来在aws上运行了aws代码管道。从星期一起我就收到了这个错误:

[Container] 2017/11/16 14:46:37 Running command chmod +x buildspec_prebuild.sh && ./buildspec_prebuild.sh
Flag --email has been deprecated, will be removed in 1.13.
Login Succeeded
{
"failures": [
{
"failureReason": "Requested image not found", 
"failureCode": "ImageNotFound", 
"imageId": {
"imageTag": "approval-machine-processes"
}
}
], 
"imageIds": []
}

[Container] 2017/11/16 14:46:40 Phase complete: PRE_BUILD Success: true
[Container] 2017/11/16 14:46:40 Phase context status code: Message: 
[Container] 2017/11/16 14:46:40 Entering phase BUILD
[Container] 2017/11/16 14:46:40 Running command echo "*** BUILD:"
*** BUILD:

[Container] 2017/11/16 14:46:40 Running command chmod +x buildspec_build.sh && ./buildspec_build.sh
/usr/share/sbt/bin/sbt-launch-lib.bash: line 207: bc: command not found

在这种情况下会出现什么问题?

我的构建文件如下所示:

buildspec_build.sh

#!/bin/bash

# make code ready for docker
sbt docker:stage
cd target/docker/stage

# add port for aws to dockerfile
echo "EXPOSE 9000" >> Dockerfile

# generate docker image tag
docker build -t "$(cat /tmp/build_tag.out)" .

改变了什么? 提前谢谢

更新:

这里有更多消息:

./buildspec_build.sh: line 5: cd: target/docker/stage: No such file or directory
Sending build context to Docker daemon 194.6 kB

Step 1 : EXPOSE 9000
Please provide a source image with `from` prior to commit

[Container] 2017/11/16 15:23:13 Command did not exit successfully chmod +x buildspec_build.sh && ./buildspec_build.sh exit status 1
[Container] 2017/11/16 15:23:13 Phase complete: BUILD Success: false
[Container] 2017/11/16 15:23:13 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: chmod +x buildspec_build.sh && ./buildspec_build.sh. Reason: exit status 1
[Container] 2017/11/16 15:23:13 Entering phase POST_BUILD
[Container] 2017/11/16 15:23:13 Running command echo "*** POST-BUILD:"
*** POST-BUILD:

[Container] 2017/11/16 15:23:13 Running command chmod +x buildspec_postbuild.sh && ./buildspec_postbuild.sh
The push refers to a repository [.dkr.ecr.eu-central-1.amazonaws.com/......]
An image does not exist locally with the tag:

更新

buildspec.yml

version: 0.1
phases:
  install:
    commands:
      - echo "*** INSTALL:"
      - chmod +x buildspec_install.sh && ./buildspec_install.sh
  pre_build:
    commands:
      - echo "*** PRE-BUILD:"
      - chmod +x buildspec_prebuild.sh && ./buildspec_prebuild.sh
  build:
    commands:
      - echo "*** BUILD:"
      - chmod +x buildspec_build.sh && ./buildspec_build.sh
  post_build:
    commands:
      - echo "*** POST-BUILD:"
      - chmod +x buildspec_postbuild.sh && ./buildspec_postbuild.sh

buildspec_install.sh

#!/bin/bash
apt-get update

# install jdk
apt-get -y install software-properties-common
apt-get -y install -y python-software-properties debconf-utils
add-apt-repository -y ppa:openjdk-r/ppa
apt-get update
apt-get -y install openjdk-8-jdk
update-alternatives --config java
update-alternatives --config javac
echo "java installation ok"

# install sbt
apt-get update
apt-get -y install apt-transport-https
echo "deb https://dl.bintray.com/sbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
apt-get update
apt-get -y install sbt
echo "sbt installation ok"

pip install --upgrade awscli

buildspec_prebuild.sh

#!/bin/bash
printf "%s:%s" "$REPOSITORY_URI" "$IMAGE_TAG" > /tmp/build_tag.out
$(aws ecr get-login)

# delete old docker image
aws ecr batch-delete-image --repository-name $REPOSITORY_NAME --image-ids imageTag=$IMAGE_TAG

echo "old docker images"

0 个答案:

没有答案