Using ANT While Hiding Your SVN Password

February 7, 2007 by Jim · 3 Comments 

I’ve been messing around with ANT (within Eclipse) to push my projects out to our development server. I’ve got a build script now that checks out the latest code from our repository, cleans it up a bit and then copies it to the server.

One thing which has bothered me is in order for the script to interact with SVN I need to pass it my login information. I could either hard code that within the script (really bad) or have a dialog popup and I can type it in – this is easy using the built in Ant taskinput‘:

Doing a bit of searching I found the Jera Ant Tasks which includes a query task:

The Query Ant task was written so that sensitive information like logins and passwords doesn’t need to be included in a build.xml file.

Using the query task is very much like the input task but it has a special password attribute. If set to true anything entered in the input field will be shown as ***** instead of the actual characters entered.

Simply download the Jera jar file (JeraAntTasks.jar) and place in the appropriate location so Ant can find it.  Then modify your Ant file:

<taskdef name="query" classname="com.jera.anttasks.Query" />

And define your input:

<query name="sql.password" message="Enter the password" password="true" />

The user will be prompted with an input dialog but when they enter their password it will be hidden with ********!

Possibly Related:

  • No related posts found.

Comments

3 Responses to “Using ANT While Hiding Your SVN Password”
  1. Abdul Qabiz says:

    I have been using ANT but not with eclipse. If I am on windows, SVN password is cached and I don’t have to put password in out build-scripts, I guess same works for MacOSX as long as your build-script is in SVNed directory?

    I did some experiment to setup build-machine for Flash/Flex stuff, where I created an account called build-master in SVN server. This machine has ssshd running. Whenever I have to push bits to staging or dev, I commit my code (after local testing/verification) from my machine, kick the build on build-machine over ssh..

    I used SVN libs for ANT, to inject some revision related info in code so it can be determined who kicked the build… It makes sense binaries (debug version) also contain some info to show the last commit version…You can always figure out rest of details from Trac, if you have it integrated…

    I believe, process should be automated you don’t have to enter things every time..It becomes painful after sometime :)

    -abdul

  2. Jim says:

    We’re using SVN over HTTPS so we need to authenticate against that…

    I agree about automation – but in our environment someone else may need to run this build script so they would have to authenticate using their credentials – not mine. :)

    I’m also doing some ‘injection’ to write the current revision into my page headers.

Trackbacks

Check out what others are saying about this post...
  1. [...] ← Using ANT While Hiding Your SVN Password [...]



Tell us what you're thinking...