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

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:${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 "" 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
Community showcase
Posted Tuesday in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

185 views 4 1
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