How to create an automatic deployment script?

I need to create a way to get a local WAR file deployed to a Linux server. What I have done so far is the following process:

  • Download WAR using WinSCP.
  • SSH to the server using PuTTY.
  • Move / rename / delete specific file folders to prepare for a WAR explosion.
  • Explosion WAR.
  • Send an email notifying users of a reboot.
  • Stop the Tomcat server.
  • Use tail to make sure the server is stopped correctly.
  • Change the symbolic link to indicate an exploded WAR.
  • Launch Tomcat.
  • Use tail to verify that the server is running correctly.
  • Send an email notifying users of a completed restart.

All this is pretty simple. And I'm sure there is a million and one other way to do this. I'd love to hear about some options. My first thought was a Bash script. I have very little experience writing scripts in general, but I thought it would be a good way to find out. I would also be interested in doing this with Ruby / Python or something like that, since I have little experience with these languages. I think that as a young developer, I should definitely get some kind of scripting language under my belt. I may also be interested in some kind of software solution that could do this for me, although I believe that scripting would be the best way to simplify and customize (maybe I just made that word).

Some relevant questions for those who have done this so far. In what language would you recommend automating the process I specified above? Will this be a good opportunity for me to learn Bash / Ruby / Python / something else, or will I just take 10 minutes to do it manually 2-3 times a week? I think the answer to this is obviously not. Can I automate these things from my computer, or do I need to configure scripts to run on a Linux server? Is email something that I can automate, or am I better off doing this part myself?

More questions will almost certainly come, as I am doing it this way, thanks to everyone in advance.

UPDATE

I must mention, I am using Maven to create a WAR. Therefore, if I can do all this with Maven, please let me know.

+6
deployment automation
source share
3 answers

It may be too hard for your needs, but have you looked at build automation tools like CruiseControl or Hudson ? You can also look at Integrity , which is lighter and written in Ruby (instead of Java, like the other two mentioned by me). These tools can do everything you say, what you need in the question, plus, and much more.

Edit

Since you want this to be a more educational exercise in scripting languages ​​than a practical solution, here's an idea for you. Instead of manually uploading your WAR each time to your server, configure a repository on your server here , here , and especially here ) that runs a Ruby (or ant or maven) script every time a set of changes is transferred from a remote computer (then to your local workstation). You must write a script so that all action items in your list are higher. Thus, you will learn about three new things: the distributed version control paradigm, how to configure this tool and how to write Ruby scripts to interact with your operating system (since your actions are very difficult for the file system).

+5
source share

The most common in my experience is ant, it is worth learning, all this is quite simple and very useful.

You should definitely automate it, and you should strive to make this happen in one step.

+2
source share

What do you use to create the WAR file itself? There is an advantage in using the same tool for assembly and deployment. In several projects, I used Ant to create a Java project and deploy it to servers.

0
source share

All Articles