Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,408
Community Members
 
Community Events
177
Community Groups

Unable to upload generated jar to s3

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

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

Atlassian Community Events