UPLOAD_ARTIFACTS State: FAILED

0

I pushed below buildspec.yml in the TestRepo via codecommit

version: 0.2


phases:
  install:
    runtime-versions:
      java: corretto8 
  build:
    commands:
      - echo Build started on `date`
      - mvn test
      - mvn package
      - echo Build completed on `date`
artifacts:
  files:
    - target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar

in the Codebuild execution process i am getting below error in the console:

[Container] Skipping invalid file path target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar [Container] Phase complete: UPLOAD_ARTIFACTS State: FAILED [Container] Phase context status code: CLIENT_ERROR Message: no matching artifact paths found

  • It must be related to the files artifact. Where is located?

  • @alatech, files artifact is under D:/ drive and below file structure

    D:--Project | TestRepo--gradle | --src | --build.gradle | --buildspec.yml | --docker-compose.yml | --gradlew | --gradlew.bat | --LICENSE.txt | --mvnw | --mvnw.cmd | --pom.xml | --readme.md | --settings.gradle

Nihar
asked a year ago1600 views
2 Answers
0

Hello,

I hope you're doing well! I understand that you encountered UPLOAD_ARTIFACTS State: FAILED in your CodeBuild project. So, please add dir command before artifacts (build or post_build phase).

Here is an example.

version: 0.2
phases:
  install:
    runtime-versions:
      java: corretto8 
  build:
    commands:
      - echo Build started on `date`
      - mvn test
      - mvn package
      - echo Build completed on `date`
      - dir target
artifacts:
  files:
    - target/spring-petclinic-2.3.0.BUILD-SNAPSHOT.jar
AWS
Daein_C
answered a year ago
  • @Daein_C, Thanks for your quick response. I used buildspec as suggested by you and re-run the build but again hopeless. While debugging the "Phase Detail" tab, error occured at two phases

    BUILD Failed COMMAND_EXECUTION_ERROR: Error while executing command: mvn test. Reason: exit status 1

    UPLOAD_ARTIFACTS Failed CLIENT_ERROR: no matching artifact paths found

    Even after installing to "correctto11" in local machine (in CMD java -version pointing to 11), i am getting below error [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.4:build-info (default) on project spring-petclinic: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:3.0.4:build-info failed: Unable to load the mojo 'build-info' in the plugin 'org.springframework.boot:spring-boot-maven-plugin:3.0.4' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/springframework/boot/maven/BuildInfoMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

  • @Nihar,

    Could you try correntto17? Java 17 is the default compiler of Spring Boot Maven Plugin

    You can use Amazon Linux 2 x86_64 standard:4.0 or Ubuntu standard:6.0. CodeBuild Available runtimes

  • @Daein_C, Still i am facing issue in uploading artifacts files to S3 bucket. Below is error log snippet capture for your reference

    [Container] 2023/03/30 19:29:25 Running command echo $CODEBUILD_SRC_DIR
    /codebuild/output/src327652445/src/git-codecommit.ap-south-1.amazonaws.com/v1/repos/TestRepo
    
    [Container] 2023/03/30 19:29:25 Running command echo Build completed on `date`
    Build completed on Thu Mar 30 19:29:25 UTC 2023
    
    [Container] 2023/03/30 19:29:25 Phase complete: BUILD State: SUCCEEDED
    [Container] 2023/03/30 19:29:25 Phase context status code:  Message: 
    [Container] 2023/03/30 19:29:25 Entering phase POST_BUILD
    [Container] 2023/03/30 19:29:25 Phase complete: POST_BUILD State: SUCCEEDED
    [Container] 2023/03/30 19:29:25 Phase context status code:  Message: 
    [Container] 2023/03/30 19:29:25 Expanding base directory path: .
    [Container] 2023/03/30 19:29:25 Assembling file list
    [Container] 2023/03/30 19:29:25 Expanding .
    [Container] 2023/03/30 19:29:25 Expanding file paths for base directory .
    [Container] 2023/03/30 19:29:25 Assembling file list
    [Container] 2023/03/30 19:29:25 Expanding target/spring-petclinic-3.0.0.BUILD-SNAPSHOT.jar
    [Container] 2023/03/30 19:29:26 Skipping invalid file path target/spring-petclinic-3.0.0.BUILD-SNAPSHOT.jar
    [Container] 2023/03/30 19:29:26 Phase complete: UPLOAD_ARTIFACTS State: FAILED
    [Container] 2023/03/30 19:29:26 Phase context status code: CLIENT_ERROR Message: no matching artifact paths found
    
  • Hi @Nihar,

    have you checked the file (target/spring-petclinic-3.0.0.BUILD-SNAPSHOT.jar) exists?

  • Hi @Daein_C, I have checked the codecommit "TestRepo" the main Repo and there is no directory called "Target" Please let me know, if i am going wrong somewhere in builcode and codecommit and user permission, since no where in console error any permission violation.

0

Hi Daein_C, Thanks for your support. After long hours of try in weekend i could able to get the root cause and want to highlight here

  1. I can't understand why you are trying to find from the codecommit repo ==> Codebuild Source is selected as "AWS CodeCommit", so basically what ever code build command are available in builspec.yml will directly apply on-cloud Repo rather to local copy in the system
  2. In project both pom and buildspec files are out of sync for the given JAR file name, for which codebuild is not able to locate the files. After fixing the JAR file name it directly uploaded the JAR file to S3 bucket
  3. Here in buildspec, no need to add extra build command -dir target. Maven will take care automatically (from file command) when uploading the JAR file.
Nihar
answered a year ago
  • Hi Nihar,

    Good to hear you fixed the issue.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions