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

What is the easiest way to deploy an bitbucket pipeline artifacts to a remote server Edited

I have been looking at the documentation most of the documentation explains. 

Here are my requirements

1. java project

2. pipeline uses custom image (with ssh installed)

3. create artifact jar, ear or whatever 

4. Deploy that artifact to a remote servers (QA, TST and PROD) via ssh. 

 

step 4 is where I am struggling with. Followed this document but I am struck at Step 2: Update the known hosts while I get an error as "unable to fetch fingerprints ....." 

I am unsure of step 3 should I be adding known hosts file to the remote server or my custom docker image. I believe its remote server but then how does my custom docker image talk to the remote host? 

Is there any documentation on of easy way to deploy the artifact to a remote server. 

1 answer

0 votes

Hi @Srikanth Mamidala ,

Regarding the error "unable to fetch fingerprints", is the server you want to deploy to behind a firewall? If so, you may need to whitelist the IP addresses listed on the following page, for the server to be able to communicate with Bitbucket:

Your network administrator may need to make specific network configuration changes to permit SSH connectivity from your server to Bitbucket.

I am unsure of step 3 should I be adding known hosts file to the remote server or my custom docker image. I believe its remote server but then how does my custom docker image talk to the remote host?

The public key should be added to your remote server (not your custom image). If you have generated an SSH key pair from this repo's Repository settings > SSH keys (or if you have added one there yourself), the private SSH key will be available in your Pipelines builds and the public key will exist on your remote server, so you'll be able to ssh from the Pipelines build to your server.

 

We have certain pipes that deploy to a remote server using SSH. If you set up SSH keys as per the documentation you mentioned, you can use one of these pipes in your bitbucket-pipelines.yml file to deploy to your server:

If your remote server has FTP, another option would be to use the following pipe to deploy via FTP (instead of SSH):

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Hello @Theodora Boudale  thank you for detailed answers. I was able to setup the connection using SCP but using a public IP only. Is there a way to enable pipelines connections for the private Ips? 

Hi @Srikanth Mamidala,

Thank you for the update, it's good to hear that you managed to set it up with SCP.

I don't believe that it is possible to use a private IP address, as private IP addresses are used within a local network. Bitbucket Pipelines needs to be able to reach your server over the internet and this can be done with a public IP address.

Kind regards,
Theodora

Got it thank you. But there may be use cases similar to mine for others as well, whats the ideal Atlassian suggested workaround for these situations? Use a jump box or something? if use a jumpbox which pipe would support that 

Hi @Srikanth Mamidala, please allow me to check with my team regarding your last question and I'll get back to you on that.

Hi @Srikanth Mamidala,

Thanks for your patience as we've been looking into this.

It should actually be possible to deploy to one of your local machines that doesn't have access to the internet with the scp-deploy pipe, using a jumpbox.

  • You will need to add the Pipelines public SSH key to the authorized_keys of both the jump server and the machine you will be deploying to
  • You will need to add the address of the jump server in the 'Known hosts' of the repo (in the page Repository settings > SSH keys)

The pipe should then be configured as follows:

pipelines:
default:
- step:
script:
- pipe: atlassian/scp-deploy:1.1.0
variables:
USER: <USER>
SERVER: <PRIVATE_IP>
REMOTE_PATH: <REMOTE_PATH>
LOCAL_PATH: '*'
DEBUG: 'true'
EXTRA_ARGS: ['-o', 'ProxyJump <JUMP_SERVER_ADDRESS>:<SSH_PORT>', '-o', 'StrictHostKeyChecking=no', '-o UserKnownHostsFile=/dev/null']

So this is possible by using the ProxyJump argument of the scp command, and also by using the options 'StrictHostKeyChecking=no' and '-o UserKnownHostsFile=/dev/null'. You need to also make sure that the jump server can communicate with the local machine you want to deploy to.

Some other suggestions we can make apart from the above setup:

- You can use a proxy server, deploy there with the pipe, and configure the proxy server to redirect the traffic to one of the machines in your local network

- You can also explore using Bitbucket Pipelines Runners, which can be run in your own network infrastructure and run your deployment there:

https://community.atlassian.com/t5/Bitbucket-Pipelines-articles/Bitbucket-Pipelines-Runners-is-now-in-open-beta/ba-p/1691022

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

Bitbucket Pipelines Runners is now in open beta

We are excited to announce the open beta program for self-hosted runners. Bitbucket Pipelines Runners is available to everyone. Please try it and let us know your feedback. If you have any issue...

3,650 views 63 19
Read article

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