Pipelines, Refer to artifact of previous step

I have defined a pipeline with 2 steps: Maven build for war generation and copy war to aws S3.

(project details replaced with 'projectname')

====================================================

image: maven:3.3.9

pipelines:
custom:
master:
- step:
name: war creation
caches:
- maven
script: # Modify the commands below to build your repository.
- cd projectname
- mvn -B clean install # -B batch mode makes Maven less verbose
- curl -X POST --user "${BB_AUTH_STRING}" "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"target/project.war"
artifacts:
- $BITBUCKET_CLONE_DIR/projectname/target/project.war
- step:
name: pip install and deploy to s3
image: node:7.5.0
caches:
- node
- pip
script:
- echo $BITBUCKET_CLONE_DIR
- apt-get update && apt-get install -y python-dev
- curl -O https://bootstrap.pypa.io/get-pip.py
- python get-pip.py
- pip install awscli --upgrade
- aws --version
- aws --debug --region ap-south-1 s3 cp $BITBUCKET_CLONE_DIR/projectname/target/project.war s3://bucketname/project.war

====================================================

The WAR file gets created in the first step and i get log entry

-> [INFO] Building war: /opt/atlassian/pipelines/agent/build/projectname/target/project.war

I have used 'artifacts' command to ensure access to project.war in the next step.

But i always get error when accessing the war file in the next step

->RuntimeError: The user-provided path /opt/atlassian/pipelines/agent/build/projectname/target/project.war does not exist.

 

Is there anything i am not doing properly?

 

1 answer

0 votes

Hi Pravin,

Can you try replace:

artifacts:
- $BITBUCKET_CLONE_DIR/projectname/target/project.war

With

artifacts:
- projectname/target/project.war

The artifacts are assumed to already be under the $BITBUCKET_CLONE_DIR. So, you including that is probably resulting is some weird behaviour causing your artifacts to not transfer.

You can also verify the artifact is transferred correct by just verifying the existance of the directory and its container files with some 'ls' commands.

Thanks,

Phil

Alternatively, you might need to use

artifacts:
- projectname/target/**

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

640 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot