Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to upload generated jar to s3

Rahul Kumar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 26, 2022

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.
- 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.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 1, 2022

Hi @Rahul Kumar 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:

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events