Unable to upload generated jar to s3
Asked by Rahul Kumar:

![Capture.JPG](/t5/image/serverpage/image-id/185565iFCD4E52D127B10C7/image-dimensions/441x306?v=v2 "Capture.JPG")

bitbucket-pipelines.yml

# Template maven-build

# This template allows you to test and build your Java project with Maven.  
# The workflow allows running tests, code checkstyle and security scans on the default branch.

# Prerequisites: pom.xml and appropriate project structure should exist in the repository.

image: maven:3.6.3

pipelines:  
default:  
#- parallel:  
- step:  
name: Build and Test  
caches:  
- maven  
script:  
- mvn -B verify --file pom.xml  
- mvn clean install  
artifacts:  
- /opt/atlassian/pipelines/agent/build/target/email-service-v1.0.jar  
after-script:  
# Collect checkstyle results, if any, and convert to Bitbucket Code Insights.  
- pipe: atlassian/checkstyle-report:0.3.0  
- step:  
name: Upload to S3  
script:  
- pipe: atlassian/aws-code-deploy:1.1.0  
variables:  
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION  
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID  
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY  
APPLICATION_NAME: $APPLICATION_NAME  
S3_BUCKET: $S3_BUCKET  
COMMAND: 'upload'  
ZIP_FILE: 'email-service-v1.0.jar'  
- step:  
name: Deploy to AWS Code deployment Group  
script:  
- pipe: atlassian/aws-code-deploy:1.1.0  
variables:  
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION  
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID  
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY  
APPLICATION_NAME: $APPLICATION_NAME  
DEPLOYMENT_GROUP: $DEPLOYMENT_GROUP  
S3_BUCKET: $S3_BUCKET  
WAIT_INTERVAL: 60  
COMMAND: 'deploy'  
WAIT: 'true'  
ZIP_FILE: 'email-service-v1.0.jar'  
IGNORE_APPLICATION_STOP_FAILURES: 'true'  
FILE_EXISTS_BEHAVIOR: 'OVERWRITE'  
- step:  
name: Security Scan  
script:  
# Run a security scan for sensitive data.  
# See more security tools at [https://bitbucket.org/product/features/pipelines/integrations?\&category=security](https://bitbucket.org/product/features/pipelines/integrations?&category=security)  
- pipe: atlassian/git-secrets-scan:0.5.1  
========================================  
I am getting below error in step2 -  
INFO: Uploading email-service-v1.0.jar to S3.  
INFO: Found credentials in environment variables.  
Traceback (most recent call last):  
File "/pipe.py", line 264, in <module>  
pipe.run()  
File "/pipe.py", line 254, in run  
self.upload_to_s3()  
File "/pipe.py", line 230, in upload_to_s3  
with open(self.get_variable('ZIP_FILE'), 'rb') as zip_file:  
FileNotFoundError: [Errno 2] No such file or directory: 'email-service-v1.0.jar'  
Please help me to get out of the problem.


Answers:
author: Theodora Boudale
body: Hi [@Rahul Kumar](/t5/user/viewprofilepage/user-id/4778871) and welcome to the community!

After taking a look at your yml file, I see the following issues:

**1.** In the first step, the **artifacts** definition includes an absolute path to the artifact *email-service-v1.0.jar*

Paths should be relative to the clone directory ( /opt/atlassian/pipelines/agent/build/ ), so you need to change the definition as follows:

```
artifacts:
  - target/email-service-v1.0.jar
```

**2.** In the second step, the value of **ZIP_FILE** is a jar file.

According to the documentation for the pipe, supported file types are: zip, tar, tgz, YAML or JSON. See here:

* <https://bitbucket.org/atlassian/aws-code-deploy/src/master/>

You can add a command to zip the file *email-service-v1.0.jar* and then pass this .zip file to the pipe, instead of the .jar

**3.** The pipe will try to find the file you defined in ZIP_FILE in the clone directory ( /opt/atlassian/pipelines/agent/build/ ).

If you create a zip file for the jar named e.g. email-service-v1.0.zip and this zip exists in the directory /opt/atlassian/pipelines/agent/build/target/, you can adjust the value of ZIP_FILE in the pipe command as follows

```
ZIP_FILE: 'target/email-service-v1.0.zip'
```

Please feel free to let me know how it goes and if you have any questions.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud