2017-03-02 68 views
2

我想在aws中創建一個代碼生成項目。我已成功配置了代碼構建項目,並且代碼也正在構建,但是測試報告沒有在指定的S3存儲桶中創建,我已經在buildspec.yml中指定了這些構件,但仍未生成報告。以下是我的buildspec.yml文件。AWS Code Build - 在S3 Bucket中沒有生成報告

version: 0.1 
    phases: 
    install: 
    commands: 
     - echo Logging in to Amazon ECR... 
     - npm install 
    pre_build: 
    commands: 
     - echo nothing to do in pre-build 
    build: 
    commands: 
     - echo Build started on `date` 
     - echo Building the Server ...   
     - npm test 
    post_build: 
    commands: 
     - echo Build completed on `date` 
    artifacts: 
    files: 
     - buildreport.txt 
    discard-paths: yes 

我也指定了S3 Bucket上傳/創建文件的適當權限。下面是我的成功構建後得到生成日誌 -

[Container] 2017/03/09 17:02:01 Phase context status code: Message: 
[Container] 2017/03/09 17:02:01 Entering phase POST_BUILD 
[Container] 2017/03/09 17:02:01 Running command echo Build completed on `date` 
[Container] 2017/03/09 17:02:01 Build completed on Thu Mar 9 17:02:01 UTC 2017 
[Container] 2017/03/09 17:02:01 Running command echo $CODEBUILD_SRC_DIR 
[Container] 2017/03/09 17:02:01 /tmp/src021393076/src 
[Container] 2017/03/09 17:02:01 Phase complete: POST_BUILD Success: true 
[Container] 2017/03/09 17:02:01 Phase context status code: Message: 
[Container] 2017/03/09 17:02:01 Preparing to copy artifacts 
[Container] 2017/03/09 17:02:01 Expanding base directory path 
[Container] 2017/03/09 17:02:01 Assembling file list 
[Container] 2017/03/09 17:02:01 Expanding . 
[Container] 2017/03/09 17:02:01 Found . 
[Container] 2017/03/09 17:02:01 Expanding artifact file paths for base directory . 
[Container] 2017/03/09 17:02:01 Assembling file list 
[Container] 2017/03/09 17:02:01 Expanding my-build 
[Container] 2017/03/09 17:02:01 Skipping invalid artifact path my-build 
[Container] 2017/03/09 17:02:01 Phase complete: UPLOAD_ARTIFACTS Success: false 
[Container] 2017/03/09 17:02:01 Phase context status code: ARTIFACT_ERROR Message: No matching artifact paths found 
[Container] 2017/03/09 17:02:01 Runtime error (No matching artifact paths found) 

我對齊和改變buildspec.yml略微低於後再次嘗試 -

version: 0.1 

phases: 
    install: 
    commands: 
     - echo Logging in to Amazon ECR... 
     - npm install 
    pre_build: 
    commands: 
     - echo nothing to do in pre-build 
    build: 
    commands: 
     - echo Build started on `date` 
     - echo Building the Server ...   
     - npm test 
    post_build: 
    commands: 
     - echo Build completed on `date` 
     - echo $CODEBUILD_SRC_DIR 
artifacts: 
    files: 
    - my-build 

但它仍然無法產生在S3文物夾。

+0

你有沒有找到解決方案? – Justin

+0

不,我不能不管我在文件參數中設置的工件,它不起作用。這迫使我切換到詹金斯。 – Jeet

回答

1

(編輯)您的壓痕是不完全正確:

artifacts:

必須比的

phases孩子少縮進,

否則artifacts將被視爲一個孩子phases(或post_build等)。雖然在YAML中有間隔的靈活性,但您的初始buildspec不符合所需的結構:請參閱AWS buildspec docs

+0

真的很重要嗎? – Jeet

+0

我嘗試縮進後嘗試,但問題仍然存在。我用新發現更新了主要問題。 – Jeet

+0

在您的修訂版本中,您是否將aws cloudformation模板與codebuild buildspec混合在一起?還有額外的引號 – joelb