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

This widget could not be displayed.

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 Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,310 views 8 11
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