Error while deploying maven project to AWS Elastic Beanstalk
Asked by AWS Developer:

Pipeline code:  
DEV-Content-Processor-Beanstalk:  
- step:  
name: mvn build  
image: maven:3.6.1  
script:  
- cd ContentProcessor  
- mvn -B clean install  
artifacts:  
- target/\*.jar

- step:  
name: Update Lambda code  
script:  
- pipe: atlassian/aws-elasticbeanstalk-deploy:0.6.6  
variables:  
AWS_ACCESS_KEY_ID: ${AWS_DEV_ACCESS_KEY_ID}  
AWS_SECRET_ACCESS_KEY: ${AWS_DEV_SECRET_KEY}  
AWS_DEFAULT_REGION: 'us-east-1'  
APPLICATION_NAME: 'ContentProcessor-app'  
ENVIRONMENT_NAME: 'ContentProcessor-env'  
ZIP_FILE: 'target/ContentProcessor-0.0.1-SNAPSHOT.jar'

Error:  
Unable to find image 'bitbucketpipelines/aws-elasticbeanstalk-deploy:0.6.6@sha256:dfeaa669b57ad7943a7aeabe741caa608a287818f19b24aec7f57c' locally  
docker.io/bitbucketpipelines/aws-elasticbeanstalk-deploy@sha256:dfeaa669b57ad7943a7aeabe741caa608a287818f19b24aec7f57c: Pulling from bitbucketpipelines/aws-elasticbeanstalk-deploy  
5d20c808ce19: Pulling fs layer  
...  
96d448f11450: Pull complete  
a36d5e990e62: Pull complete  
Digest: sha256:dfeaa669b57ad7943a7aeabe741caa608a287818f19b24aec7f57c  
Status: Downloaded newer image for bitbucketpipelines/aws-elasticbeanstalk-deploy@sha256:dfeaa669b57ad7943a7aeabe741caa608a287818f19b24aec7f57c  
INFO: The application source bundle doesn't have a known file extension (zip, jar or war). This might cause some issues.  
INFO: Uploading to s3 bucket: ContentProcessor-elasticbeanstalk-deployment...  
The user-provided path target/ContentProcessor-0.0.1-SNAPSHOT.jar does not exist.

Issue: Deployment failed.

Please let me know, What is the issue here? Is there a way to troubleshoot it in local.?


Answers:
author: Caroline R
body: Hi, [@AWS Developer](/t5/user/viewprofilepage/user-id/4572869)! Welcome to the community!

By the error message you shared in your description, it looks like the file you are trying to upload doesn't exist - **target/ContentProcessor-0.0.1-SNAPSHOT.jar**

Could you please verify that? You can first check if the file exists or not in the Update Lambda code step before calling the Pipe:

    - step:name: Update Lambda codescript:- ls -lrt target- pipe: atlassian/aws-elasticbeanstalk-deploy:0.6.6variables:AWS_ACCESS_KEY_ID: ${AWS_DEV_ACCESS_KEY_ID}AWS_SECRET_ACCESS_KEY: ${AWS_DEV_SECRET_KEY}AWS_DEFAULT_REGION: 'us-east-1'APPLICATION_NAME: 'ContentProcessor-app'ENVIRONMENT_NAME: 'ContentProcessor-env'ZIP_FILE: 'target/ContentProcessor-0.0.1-SNAPSHOT.jar'

Please feel free to share any additional questions regarding this case.

Kind regards,  
Caroline

comments: author: AWS Developer
body: Thank you for looking into this issue, Caroline.

Please find the logs for *ls -lrt target*

*+ ls -lrt target*   
*ls: cannot access target: No such file or directory*

I verified that, Jar was created during the step1(mvn build), but it was missing, during step2(deployment to Beanstalk). If I run both "mvn build" and deployment commands in the same step, then it works fine.

I need to execute build and deployment in separate steps.

- Can you please advice, what could be the issue with this pipeline?

**mvn build log:**

*mvn -B clean install*

*...*

*\[INFO\] Installing /opt/atlassian/pipelines/agent/build/processor/target/ContentProcessor-0.0.1.jar to /root/.m2/repository/com/myapp/processor/0.0.1/ContentProcessor-0.0.1.jar*   
*\[INFO\] Installing /opt/atlassian/pipelines/agent/build/processor/pom.xml to /root/.m2/repository/com/myapp/processor/0.0.1/ContentProcessor-0.0.1.pom*   
*\[INFO\] ------------------------------------------------------------------------*   
*\[INFO\] BUILD SUCCESS*   
*\[INFO\] ------------------------------------------------------------------------*   
*\[INFO\] Total time: 36.346 s*

*Build teardown
You already have a 'maven' cache so we won't create it again
Cache "maven": Skipping upload for existing cache
Searching for files matching artifact pattern target/\*
Searching for test report files in directories named \[test-results, failsafe-reports, test-reports, surefire-reports\] down to a depth of 4
Finished scanning for test reports. Found 0 test report files.
Merged test suites, total number tests is 0, with 0 failures and 0 errors.*

**deployment log:**   
*Status: Downloaded newer image for bitbucketpipelines/aws-elasticbeanstalk-deploy@sha256:dfe2e669b57ad7943a7aeabe741c43db57c863aa608a287818f19b24aec7f57c*   
*INFO: The application source bundle doesn't have a known file extension (zip, jar or war). This might cause some issues.*   
*INFO: Uploading to s3 bucket: test-bitbucket-ebs...*   
*The user-provided path target/ContentProcessor-0.0.1.jar does not exist.*

<br />

**updated pipeline:**

*DEV-ContentProcessor-Beanstalk:*   
*- step:*   
*name: mvn build*   
*image: maven:3.6.1*   
*caches:*   
*- maven*   
*script:*   
*- cd processor*   
*- mvn -B clean install*   
*artifacts:*   
*- target/\**   
*- step:*   
*name: Update Beanstalk code*   
*script:*   
*- cd processor*   
*- pipe: atlassian/aws-elasticbeanstalk-deploy:0.6.6*   
*variables:*   
*AWS_ACCESS_KEY_ID: ${AWS_DEV_ACCESS_KEY_ID}*   
*AWS_SECRET_ACCESS_KEY: ${AWS_DEV_SECRET_KEY}*   
*AWS_DEFAULT_REGION: 'us-east-1'*   
*APPLICATION_NAME: 'ContentProcessor-app'*   
*ENVIRONMENT_NAME: 'ContentProcessor-env'*   
*ZIP_FILE: 'target/ContentProcessor-0.0.1.jar'*   
*S3_BUCKET: ${AWS_DEV_S3_BUCKET_CONTENT}*


author: Caroline R
body: Hi, [@AWS Developer](/t5/user/viewprofilepage/user-id/4572869)!

Thank you for getting back to me and sharing the additional information.

As per the teardown log, it looks like no file was uploaded as artifacts as there is no matching file. It searches for the files but doesn't upload anything in the artifacts because it doesn't find anything:

    Searching for files matching artifact pattern target/*Finished scanning for test reports. Found 0 test report files.

In this case, could you please add **ls -lrt** in the first step as well and share this here?

```
script:- cd ContentProcessor- mvn -B clean install- ls -lrt target
```

Thank you. Looking forward to hearing from you.

Kind regards,  
Caroline


author: AWS Developer
body: ```
mvn -B clean install 12s

ls -lrt target <1s
+ ls -lrt target
total 53968
drwxrwxrwx 3 root root 4096 Sep 29 07:30 generated-sources
drwxrwxrwx 3 root root 4096 Sep 29 07:30 maven-status
drwxrwxrwx 3 root root 4096 Sep 29 07:30 classes
drwxrwxrwx 3 root root 4096 Sep 29 07:30 generated-test-sources
drwxrwxrwx 3 root root 4096 Sep 29 07:30 test-classes
drwxrwxrwx 2 root root 4096 Sep 29 07:31 maven-archiver
-rw-rw-rw- 1 root root 343070 Sep 29 07:31 ContentProcessor-0.0.1.jar.original
-rw-rw-rw- 1 root root 54892065 Sep 29 07:31 ContentProcessor-0.0.1.jar

Build teardown <1s
You already have a 'maven' cache so we won't create it again
Cache "maven": Skipping upload for existing cache
Searching for files matching artifact pattern target/*
Searching for test report files in directories named [test-results, failsafe-reports, test-reports, surefire-reports] down to a depth of 4
Finished scanning for test reports. Found 0 test report files.
Merged test suites, total number tests is 0, with 0 failures and 0 errors.
```

Jar file was present at the end of step1(maven build), but it is missing in step 2(deployment)


author: AWS Developer
body: [@Caroline R](/t5/user/viewprofilepage/user-id/3934006) , Please let me know, if you find any issues with the above pipeline.

thank you.


author: Caroline R
body: Hi, [@AWS Developer](/t5/user/viewprofilepage/user-id/4572869)!

Could you please run this command after the ls -lrt target?

    du -sh target

The above command will give us the size of the entire directory. The reason I'm asking you this is that we don't support more than 1 GB of artifacts.

We also have a public feature request for Pipeline to fail if the build's artifact size reach the 1GB limit:

* <https://jira.atlassian.com/browse/BCLOUD-17145>

Thank you!

Kind regards,  
Caroline


author: AWS Developer
body: Hi, [@Caroline R](/t5/user/viewprofilepage/user-id/3934006) ,

Please find the output. Jar file size is 54 MB

```
DEV-ContentProcessor-Beanstalk:
- step:
name: maven build
image: maven:3.3.9
caches: 
- maven
script:
- cd processor
- mvn -B clean install
- ls -lrt target
- du -sh target
artifacts:
- target/*
- step:
name: Update Beanstalk code
script:
- cd processor
- ls -lrt target
- echo $PWD
- pipe: atlassian/aws-elasticbeanstalk-deploy:1.0.2
variables:
AWS_ACCESS_KEY_ID: ${AWS_DEV_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_DEV_SECRET_KEY}
AWS_DEFAULT_REGION: 'us-east-1'
APPLICATION_NAME: 'ContentProcessor-app'
ENVIRONMENT_NAME: 'ContentProcessor-env'
DEBUG: 'true'
ZIP_FILE: 'target/ContentProcessor-0.0.1.jar'
S3_BUCKET: ${AWS_DEV_S3_BUCKET_CONTENT}
```

Step1 logs:

```
mvn -B clean install 10s

ls -lrt target <1s
+ ls -lrt target
total 53968
drwxrwxrwx. 3 root root 4096 Oct 6 13:10 generated-sources
drwxrwxrwx. 3 root root 4096 Oct 6 13:10 maven-status
drwxrwxrwx. 3 root root 4096 Oct 6 13:10 classes
drwxrwxrwx. 3 root root 4096 Oct 6 13:10 generated-test-sources
drwxrwxrwx. 3 root root 4096 Oct 6 13:10 test-classes
drwxrwxrwx. 2 root root 4096 Oct 6 13:10 maven-archiver
-rw-rw-rw-. 1 root root 343012 Oct 6 13:10 ContentProcessor-0.0.1.jar.original
-rw-rw-rw-. 1 root root 54892007 Oct 6 13:10 ContentProcessor-0.0.1.jar

du -sh target <1s
+ du -sh target
54M target
```

Step2 logs:

```
cd ContentProcessor <1s
+ cd ContentProcessor

ls -lrt target <1s
+ ls -lrt target
ls: cannot access target: No such file or directory
?
```


author: Caroline R
body: Hi, [@AWS Developer](/t5/user/viewprofilepage/user-id/4572869).

Thanks for running the command. In this case, we will need to further investigate this code, so I went ahead and created a support ticket for you using the email of your community account, this way our support team will be able to access this repository with your approval.

You should have received an email with a link to the support ticket. Just in case you haven't received it, please feel free to let me know and I can post the ticket URL here. The ticket will be visible only to you and Atlassian staff, no one else can view its contents even if they have the URL.

Please feel free to let me know if you have any questions.  
Kind regards,  
Caroline


author: AWS Developer
body: [@Caroline R](/t5/user/viewprofilepage/user-id/3934006) ,

I found that it was an issue with the target path. Since i added multiple source and targets to pipeline yml, it was causing a conflict. It is working after moving it to new repository.

Thank you for your support.


author: Caroline R
body: Hi, [@AWS Developer](/t5/user/viewprofilepage/user-id/4572869)!

Thanks for the information! I'm glad to know everything is working now. I have also shared this update with the engineer who would work on your case.  
Kind regards,  
Caroline


Tags: bitbucket-pipelines

cloud