aws-deployment-framework icon indicating copy to clipboard operation
aws-deployment-framework copied to clipboard

getting error while running buildspec.yaml file-COMMAND_EXECUTION_ERROR: Error while executing command:

Open avkhaladkar1991 opened this issue 5 years ago • 5 comments

Whie running codebuild project getting error while running buildspec.yaml file-COMMAND_EXECUTION_ERROR: Error while executing command:

buildspec.yml file is as below:

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' - mvn install post_build: commands: - echo build completed on 'date' artifacts: files: - 'target/ccdemo.war'

[Container] 2020/09/27 05:47:23 Phase complete: INSTALL State: SUCCEEDED 30 | [Container] 2020/09/27 05:47:23 Phase context status code: Message: 31 | [Container] 2020/09/27 05:47:23 Entering phase PRE_BUILD 32 | [Container] 2020/09/27 05:47:23 Phase complete: PRE_BUILD State: SUCCEEDED 33 | [Container] 2020/09/27 05:47:23 Phase context status code: Message: 34 | [Container] 2020/09/27 05:47:23 Entering phase BUILD 35 | [Container] 2020/09/27 05:47:23 Running command npm test 36 | npm ERR! code ENOENT 37 | npm ERR! syscall open 38 | npm ERR! path /codebuild/output/src378222268/src/git-codecommit.us-east-2.amazonaws.com/v1/repos/ccdemo/package.json 39 | npm ERR! errno -2 40 | npm ERR! enoent ENOENT: no such file or directory, open '/codebuild/output/src378222268/src/git-codecommit.us-east-2.amazonaws.com/v1/repos/ccdemo/package.json' 41 | npm ERR! enoent This is related to npm not being able to find a file. 42 | npm ERR! enoent 43 |   44 | npm ERR! A complete log of this run can be found in: 45 | npm ERR! /root/.npm/_logs/2020-09-27T05_47_23_305Z-debug.log 46 |   47 | [Container] 2020/09/27 05:47:23 Command did not exit successfully npm test exit status 254 48 | [Container] 2020/09/27 05:47:23 Phase complete: BUILD State: FAILED 49 | [Container] 2020/09/27 05:47:23 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm test. Reason: exit status 254 50 | [Container] 2020/09/27 05:47:23 Entering phase POST_BUILD 51 | [Container] 2020/09/27 05:47:23 Phase complete: POST_BUILD State: SUCCEEDED 52 | [Container] 2020/09/27 05:47:23 Phase context status code: Message: 53 | [Container] 2020/09/27 05:47:23 Expanding base directory path: . 54 | [Container] 2020/09/27 05:47:23 Assembling file list 55 | [Container] 2020/09/27 05:47:23 Expanding . 56 | [Container] 2020/09/27 05:47:23 Expanding file paths for base directory . 57 | [Container] 2020/09/27 05:47:23 Assembling file list 58 | [Container] 2020/09/27 05:47:23 Expanding target/ccdemo.war 59 | [Container] 2020/09/27 05:47:23 Skipping invalid file path target/ccdemo.war 60

image

avkhaladkar1991 avatar Sep 27 '20 06:09 avkhaladkar1991

Hi @avkhaladkar1991, it looks like the buildspec you shared is not the one that is executed. The logs don't show the echo messages + it executes npm test (JavaScript), while your buildspec refers to maven and war files (Java).

Can you verify what buildspec it executes and what source it used? You can find both in the tabs of the CodeBuild environment. The buildspec is shown in the status page of an execution, the source is the artifact file it has linked as its input. You can save the artifact file by downloading it. Appending .zip to the file name allows you to unzip it/look inside.

I suspect that either your buildspec hasn't been committed or pushed yet, or it is using another repository at the moment.

sbkok avatar Sep 27 '20 06:09 sbkok

Hi Simon,

No I am using same file.

PFA the document ,you will get to know everything.

Regards,

On Sun, Sep 27, 2020 at 12:20 PM Simon [email protected] wrote:

Hi @avkhaladkar1991 https://github.com/avkhaladkar1991, it looks like the buildspec you shared is not the one that is executed. The logs don't show the echo messages + it executes npm test (JavaScript), while your buildspec refers to maven and war files (Java).

Can you verify what buildspec it executes and what source it used? You can find both in the tabs of the CodeBuild environment. The buildspec is shown in the status page of an execution, the source is the artifact file it has linked as its input. You can save the artifact file by downloading it. Appending .zip to the file name allows you to unzip it/look inside.

I suspect that either your buildspec hasn't been committed or pushed yet, or it is using another repository at the moment.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-deployment-framework/issues/291#issuecomment-699594447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP6Q6DERBNDXXWCVL5VPDZ3SH3OCZANCNFSM4R3LQNIA .

avkhaladkar1991 avatar Sep 27 '20 07:09 avkhaladkar1991

Unfortunately it seems the attachment didn't make it through. Could you share it as a gist or paste it in a message maybe?

sbkok avatar Sep 29 '20 08:09 sbkok

Hi Simon,

PFB.

Getting Error while running AWS Codebuild project

.yml code is

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'

  - mvn install

post_build:

commands:

  - echo build completed on 'date'

artifacts:

files:

- 'target/ccdemo.war'

Tail logs

Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/2.0.4/plexus-utils-2.0.4.jar (222 kB at 2.4 MB/s)

Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-manager/2.8.4/plexus-compiler-manager-2.8.4.jar

Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/3.2.1/maven-shared-utils-3.2.1.jar (167 kB at 1.6 MB/s)

Downloading from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.4/plexus-compiler-javac-2.8.4.jar

Downloaded from central: https://repo.maven.apache.org/maven2/org/ow2/asm/asm/6.2/asm-6.2.jar (111 kB at 1.1 MB/s)

Progress (2): 317 kB | 4.1/27 kB

Progress (2): 317 kB | 8.2/27 kB

Progress (2): 317 kB | 12/27 kB

Progress (2): 317 kB | 16/27 kB

Progress (2): 317 kB | 20/27 kB

Progress (2): 317 kB | 25/27 kB

Progress (2): 317 kB | 27 kB

Progress (3): 317 kB | 27 kB | 4.1/4.7 kB

Progress (3): 317 kB | 27 kB | 4.7 kB

Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-api/2.8.4/plexus-compiler-api-2.8.4.jar (27 kB at 222 kB/s)

Downloaded from central: https://repo.maven.apache.org/maven2/com/thoughtworks/qdox/qdox/2.0-M9/qdox-2.0-M9.jar (317 kB at 2.5 MB/s)

Progress (2): 4.7 kB | 4.1/21 kB

Progress (2): 4.7 kB | 8.2/21 kB

Progress (2): 4.7 kB | 12/21 kB

Progress (2): 4.7 kB | 16/21 kB

Progress (2): 4.7 kB | 20/21 kB

Progress (2): 4.7 kB | 21 kB

Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-manager/2.8.4/plexus-compiler-manager-2.8.4.jar (4.7 kB at 34 kB/s)

Downloaded from central: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-compiler-javac/2.8.4/plexus-compiler-javac-2.8.4.jar (21 kB at 145 kB/s)

[INFO] Changes detected - recompiling the module!

[INFO] Compiling 3 source files to /codebuild/output/src467881691/src/ git-codecommit.us-east-2.amazonaws.com/v1/repos/ccdemo/target/classes

[INFO]

[INFO] BUILD FAILURE

[INFO]

[INFO] Total time: 12.156 s

[INFO] Finished at: 2020-09-27T07:06:17Z

[INFO]

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project ccdemo: Fatal error compiling: error: invalid target release: 14 -> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

[Container] 2020/09/27 07:06:17 Command did not exit successfully mvn install exit status 1

[Container] 2020/09/27 07:06:17 Phase complete: BUILD State: FAILED

[Container] 2020/09/27 07:06:17 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: mvn install. Reason: exit status 1

[Container] 2020/09/27 07:06:17 Entering phase POST_BUILD

[Container] 2020/09/27 07:06:17 Running command echo build completed on 'date'

build completed on date

[Container] 2020/09/27 07:06:17 Phase complete: POST_BUILD State: SUCCEEDED

[Container] 2020/09/27 07:06:17 Phase context status code: Message:

[Container] 2020/09/27 07:06:17 Expanding base directory path: .

[Container] 2020/09/27 07:06:17 Assembling file list

[Container] 2020/09/27 07:06:17 Expanding .

[Container] 2020/09/27 07:06:17 Expanding file paths for base directory .

[Container] 2020/09/27 07:06:17 Assembling file list

[Container] 2020/09/27 07:06:17 Expanding target/ccdemo.war

[Container] 2020/09/27 07:06:17 Skipping invalid file path target/ccdemo.war

Here if you noticed, getting error in build phase:” [Container] 2020/09/26 16:30:17 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: mvn install. Reason: exit status 1”

Means some issue in command [mvn install]?

FYI pom/xml file is

<project xmlns="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"

   xsi:schemaLocation=*"http://maven.apache.org/POM/4.0.0

http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd https://maven.apache.org/xsd/maven-4.0.0.xsd"*>

   <modelVersion>4.0.0</modelVersion>

   <parent>

          <groupId>org.springframework.boot</groupId>

          <artifactId>spring-boot-starter-parent</artifactId>

          <version>2.2.10.RELEASE</version>

          <relativePath/> <!-- lookup parent from repository -->

   </parent>

   <groupId>com.stacksimplify</groupId>

   <artifactId>ccdemo</artifactId>

   <version>0.0.1-SNAPSHOT</version>

   <packaging>war</packaging>

   <name>ccdemo</name>

   <description>Demo project for Spring Boot</description>



   <properties>

          <java.version>14</java.version>

   </properties>



   <dependencies>

          <dependency>

                 <groupId>org.springframework.boot</groupId>

                 <artifactId>spring-boot-starter-web</artifactId>

          </dependency>



          <dependency>

                 <groupId>org.springframework.boot</groupId>

                 <artifactId>spring-boot-starter-tomcat</artifactId>

                 <scope>provided</scope>

          </dependency>

          <dependency>

                 <groupId>org.springframework.boot</groupId>

                 <artifactId>spring-boot-starter-test</artifactId>

                 <scope>test</scope>

                 <exclusions>

                       <exclusion>

                              <groupId>org.junit.vintage</groupId>

                              <artifactId>junit-vintage-engine</

artifactId>

                       </exclusion>

                 </exclusions>

          </dependency>

   </dependencies>



   <build>

          <plugins>

                 <plugin>

                       <groupId>org.springframework.boot</groupId>

                       <artifactId>spring-boot-maven-plugin</artifactId>

                 </plugin>

          </plugins>

   </build>

On Tue, Sep 29, 2020 at 2:22 PM Simon [email protected] wrote:

Unfortunately it seems the attachment didn't make it through. Could you share it as a gist https://gist.github.com or paste it in a message maybe?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-deployment-framework/issues/291#issuecomment-700558863, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP6Q6DHM7QQJ2BJGPWU4UP3SIGN35ANCNFSM4R3LQNIA .

avkhaladkar1991 avatar Sep 30 '20 04:09 avkhaladkar1991

Hi @avkhaladkar1991,

Apologies for the late reply. I'm not sure if you managed to resolve the issue in the meanwhile, but what your CodeBuild environment is complaining about is the Java version that is used.

The first error that pops-up is:

[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile
(default-compile) on project ccdemo: Fatal error compiling: error: invalid
target release: 14 -> [Help 1]

The Java version that you request in the maven file requests Java 14:

       <properties>
              <java.version>14</java.version>
       </properties>

Unfortunately Java 14 is not supported by CodeBuild yet, as can be found here.

What you could do is update the pipeline deployment map, such that CodeBuild is using a recent image, for example: "STANDARD_5_0", like this:

pipelines:
  - name: your-pipeline
    default_providers:
      source:
          # ...
      build:
        provider: codebuild
        properties:
          image: STANDARD_5_0

STANDARD_5_0 allows you to use openjdk11 or corretto11 for the Java runtime.

In the CodeBuild spec file, you would specify the Java version you need like this (see phases > install > run-time-versions):

version: 0.2
phases:
  install:
    runtime-versions:
      java: corretto11
    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'
      - mvn install
  post_build:
    commands:
      - echo build completed on 'date'
artifacts:
  files:
    - 'target/ccdemo.war'

Don't forget to update the requested Java version in the Maven file to 11 for it to work. Please let me know if you managed to resolve the error. Feel free to close the issue if it is no longer relevant.

sbkok avatar Mar 02 '21 17:03 sbkok

Thank you for your patience. I am happy to inform you that this issue has been resolved in our latest release v3.2.0 just now. I'm hereby closing this issue. Please open a new issue if you are experiencing any issues with the latest release.

sbkok avatar Jan 24 '23 10:01 sbkok