AWS CodeBuild-CD:无法CD到/ codebuild / output / src ...错误和工件路径未找到

时间:2019-01-31 16:11:46

标签: amazon-web-services aws-codebuild

===============

我是AWS CodeBuild的新手。我们是第一次尝试。我设置了Buildspec.yml文件,当我运行它时,出现错误,表明它cd:在整个构建过程中无法cd到/ codebuild / output / src ....,但是每次都会进行到下一步忽略错误。但是,当进入工件步骤时,它找不到工件路径。我已经尝试了许多工件的迭代:files:没有运气的语句。我不确定cd错误和工件问题是否相关。

这是当前的Buildspec文件。我还尝试了几种不同版本的“文件:”语句,包括-'** / *'

buildspec.yml

version: 0.2

phases:
  install:
    commands:
      - echo Nothing to do in the install phase...
  pre_build:
    commands:
      - echo Nothing to do in the pre_build phase...
  build:
    commands:
      - echo Build started on `date`
      - echo $CODEBUILD_SRC_DIR
      - uServices/hello-world-java/gradlew build
  post_build:
    commands:
      - echo Build completed on `date`
artifacts:
  files:
    - uServices/hello-world-java/build/distributions/*

代码构建的输出

[Container] 2019/01/31 14:19:42 Waiting for agent ping
[Container] 2019/01/31 14:19:43 Waiting for DOWNLOAD_SOURCE
[Container] 2019/01/31 14:19:44 Phase is DOWNLOAD_SOURCE
[Container] 2019/01/31 14:19:44 CODEBUILD_SRC_DIR=/codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
[Container] 2019/01/31 14:19:44 YAML location is /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git /buildspec.yml
[Container] 2019/01/31 14:19:44 Processing environment variables
[Container] 2019/01/31 14:19:44 Moving to directory /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
[Container] 2019/01/31 14:19:44 Registering with agent
[Container] 2019/01/31 14:19:44 Phases found in YAML: 4
[Container] 2019/01/31 14:19:44 POST_BUILD: 1 commands
[Container] 2019/01/31 14:19:44 INSTALL: 1 commands
[Container] 2019/01/31 14:19:44 PRE_BUILD: 1 commands
[Container] 2019/01/31 14:19:44 BUILD: 3 commands
[Container] 2019/01/31 14:19:44 Phase complete: DOWNLOAD_SOURCE Success: true
[Container] 2019/01/31 14:19:44 Phase context status code: Message:
[Container] 2019/01/31 14:19:44 Entering phase INSTALL
[Container] 2019/01/31 14:19:44 Running command echo Nothing to do in the install phase...
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Nothing to do in the install phase...
 [Container] 2019/01/31 14:19:44 Phase complete: INSTALL Success: true
[Container] 2019/01/31 14:19:44 Phase context status code: Message:
[Container] 2019/01/31 14:19:45 Entering phase PRE_BUILD
[Container] 2019/01/31 14:19:45 Running command echo Nothing to do in the pre_build phase...
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Nothing to do in the pre_build phase...
 [Container] 2019/01/31 14:19:45 Phase complete: PRE_BUILD Success: true
[Container] 2019/01/31 14:19:45 Phase context status code: Message:
[Container] 2019/01/31 14:19:45 Entering phase BUILD
[Container] 2019/01/31 14:19:45 Running command echo Build started on `date`
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Build started on Thu Jan 31 14:19:45 UTC 2019
 [Container] 2019/01/31 14:19:45 Running command echo $CODEBUILD_SRC_DIR
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
/codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
 [Container] 2019/01/31 14:19:45 Running command uServices/hello-world-java/gradlew build
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Downloading https://services.gradle.org/distributions/gradle-3.5-bin.zip
..........................................................................................................................................................................................................................................................................................
Unzipping /root/.gradle/wrapper/dists/gradle-3.5-bin/daoimhu7k5rlo48ntmxw2ok3e/gradle-3.5-bin.zip to /root/.gradle/wrapper/dists/gradle-3.5-bin/daoimhu7k5rlo48ntmxw2ok3e
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-3.5-bin/daoimhu7k5rlo48ntmxw2ok3e/gradle-3.5/bin/gradle
Starting a Gradle Daemon (subsequent builds will be faster)
:buildEnvironment
 ------------------------------------------------------------
Root project
------------------------------------------------------------
 classpath
No dependencies
 BUILD SUCCESSFUL
 Total time: 8.74 secs
 [Container] 2019/01/31 14:19:56 Phase complete: BUILD Success: true
[Container] 2019/01/31 14:19:56 Phase context status code: Message:
[Container] 2019/01/31 14:19:56 Entering phase POST_BUILD
[Container] 2019/01/31 14:19:56 Running command echo Build completed on `date`
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Build completed on Thu Jan 31 14:19:56 UTC 2019
 [Container] 2019/01/31 14:19:56 Phase complete: POST_BUILD Success: true
[Container] 2019/01/31 14:19:56 Phase context status code: Message:
[Container] 2019/01/31 14:19:56 Expanding base directory path: .
[Container] 2019/01/31 14:19:56 Assembling file list
[Container] 2019/01/31 14:19:56 Expanding /codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
.
[Container] 2019/01/31 14:19:56 Expanded to /codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
.
[Container] 2019/01/31 14:19:56 Skipping invalid artifact path /codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
.

[容器] 2019/01/31 14:19:56完成阶段:UPLOAD_ARTIFACTS成功:否 [容器] 2019/01/31 14:19:56相上下文状态代码:CLIENT_ERROR消息:未找到/codebuild/output/tmp/script.sh的匹配基本目录路径:1:cd:无法cd到/ codebuild /output/src590503358/src/github.com/SomosEngineering/tss-modern.git

  

摘要

     
     

在我的开发区域中,我可以运行Gradle并查看.zip工件   坐在以下目录中。我希望代码构建   找到它并将其加载到S3。 [clipford @ NVA-1a-TSS-DEV01

     

发行] $ pwd

     

/ home / clipford / work / tss-modern / uServices / hello-world-java / build / distributions

     

[clipford @ NVA-1a-TSS-DEV01发行] $ ls

     

tss-modern-clipford.zip

1 个答案:

答案 0 :(得分:0)

我最终尝试从亚马逊S3容器中构建此产品,从而使构建工作完全正常。然后,我回到了GitHub版本,与无法CD到codebuild目录有关的问题神奇地消失了。 (我也不相信魔术,但假设这是一个亚马逊问题)。

工件没有加载的问题与以下事实有关:我们项目中的工件位于不属于GitHub存储库的目录中。实际上,它在.gitignore中被忽略。构件目录是在构建时创建的,并且看来,由于它在.gitignore中被忽略,而不是仓库代码构建的一部分,因此找不到该构件,也无法将其加载到S3。