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

Pipelines, Refer to artifact of previous step

prabhupravin December 5, 2017

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?

 

3 answers

1 vote
Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 2, 2018

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

Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 2, 2018

Alternatively, you might need to use

artifacts:
- projectname/target/**
0 votes
rmazzoni February 20, 2019

I am facing the same issue, with the same result. Is there a bug?

Philip Hodder
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 3, 2019

Hi Riccardo,

Can you post the bitbucket-pipelines.yml configuration that you're using? You can check the contents of your build environment with the following commands:

pipelines:
default:
- step:
artifacts:
- # Whatever you normally have configured.
script:
- # Run your normal build commands.
- ls -R $BITBUCKET_CLONE_DIR # This will list all files in your build environment.
- ls -R $BITBUCKET_CLONE_DIR | xargs realpath | grep <file name you're looking for> # This will print the full path of a file you're looking for.

The 'Build Teardown' logs may also contain useful information for you.

Thanks,

Phil

0 votes
Allysson Pereira January 13, 2019

Hi @prabhupravin, did you do that? It works?

prabhupravin June 14, 2019

It worked when i Removed '$BITBUCKET_BUILD_NUMBER' from the generated war's name.

 

i had generated a war like 'myapplication_$BITBUCKET_BUILD_NUMBER.war' using maven; but that was not getting reflected in Artifacts.

 

used 'myapplication.war' and referred to it and it got reflected.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events