How do I specify a variable (specifically a file name) in a Bamboo SSH task?

I'm trying to create a deploy plan which:

  1. Uploads a shared artifact to a remote server using an SCP task
  2. Executes an SSH task that runs a script on the remote server that takes as its argument the name of the file to install to the app server

I have everything working up until step #2, where I'm stuck trying to find a way to execute the deploy script.

Is there any way that I can refer to the file that was uploaded as part of the SCP task? If not, what good is it to SCP a file if we cannot refer to it in future tasks?

We're using Maven for build & dependency management and each successful build increments the POM number, so the name of the file to deploy isn't static.

 

1 answer

This widget could not be displayed.

The artifact should be what you are copying in an scp task. Getting the name of the artifact in the ssh task looks like it could be tricky though.  

My initial thoughts are to put the name of the artifact in an injection variable.  But again identifying the artifact may be a problem.

I know that you can reference the artifact directory using variables and perhaps what you need to do if your ssh command is not a static value (a batch script name for example) is get a list of the files in your artifact store for that build here: http://your.org/bamboo/browse/${bamboo.planKey}-JOB1/latest/artifact  (assuming your artifacts are created in the JOB1 stage) 

If you were to retrieve that as a rest request you could parse it for the specific artifact you are looking for then put that in an injection variable.  (essentially a variable/value pair in a text file on the filesystem).  

Yes, it is clunky and a hassle to script but it will work.  

All that said we generally have the server we are deploying to run a script to pickup whatever artifact we dump there and deploy from the server side rather than trying to do it from the bamboo host.  It's just easier to do it that way for us.

For example if you have a tomcat war file to deploy, bamboo dumps the artifact in a staging location on the application server, then a cron or windows scheduled task checks the server staging location and if it finds a candidate (*.ear) deploys it.  

You could also use a script on the server that was executed by a script on the bamboo host that would do the same thing.  The difference is that you would be executing a named script "deploy.sh" or "deploy.cmd/bat/whatever" to actually deploy the artifact using wildcards in the script.

Hope this helps.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

146 views 2 0
Join discussion

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