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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Pipelines: How to upload a jar to remote server using scp Edited

Hi,

I've tried all combinations, but I could not find a way to upload a maven generated jar file to a remote server using the scp pipeline.

If I use 

LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/*'

this would copy the whole source folder structure , but without any trace of the target/ folder or any jar.

I tried this (it's a multi module project):

LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/web/target/*'

 

The build finishes successfully and the logs say uploading artifact to maven repo from:

 

/opt/atlassian/pipelines/agent/build/web/target/

 

 But then when trying the scp:

 

/opt/atlassian/pipelines/agent/build/web/target/*.jar: No such file or directory

 Thank you

 

1 answer

1 accepted

0 votes
Answer accepted

I've found the answer. It is simple. Basically, to share the artifacts produced by one step in the pipeline, with other steps, you need to use artifacts (https://confluence.atlassian.com/bitbucket/using-artifacts-in-steps-935389074.html)

 

Here's how I did it:

In the build step I declared artifacts:

pipelines:
default:
- step:
caches:
- maven
script: # Modify the commands below to build your repository.
- mvn -B install # -B batch mode makes Maven less verbose
- ls -R $BITBUCKET_CLONE_DIR # This will list all files in your build environment.
- ls -R $BITBUCKET_CLONE_DIR | xargs realpath
artifacts:
- '**/target/*.jar'

 

And then in the next step, I refer to them in the LOCAL_PATH variable of the scp-deploy pipe:

- step:
name: Deploy to server
deployment: Test
script:
- ls -R $BITBUCKET_CLONE_DIR # This will list all files in your build environment.
- ls -R $BITBUCKET_CLONE_DIR | xargs realpath
- pipe: atlassian/scp-deploy:0.3.11
variables:
USER: '${USER}'
SERVER: '${HOST}'
REMOTE_PATH: '/home/myuser/'
LOCAL_PATH: '**/target/*.jar'
- pipe: atlassian/ssh-run:0.2.5
variables:
SSH_USER: '${USER}'
SERVER: '${HOST}'
COMMAND: 'ls -l'

 The last command (in ssh-run ls -l) would show my jar files on the server.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Bitbucket

How do you use the Bitbucket-Jira integration? How does it help your team?

Hey everyone, over the past year, we've added several new features on how you can use Bitbucket and Jira together. We'd love to know how you'll are using the integration and how it's helping your t...

86 views 0 2
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you