Jenkins Job to Automate SVN Tagging

In my previous post, I gave a high-level overview of a Jenkins job that could automate creating SVN tags.  In this post, I’m going to give more details on exactly how this is done.

Step By Step

This job makes the assumption that the tag is always created from the trunk.  Now obviously, this isn’t ideal in all cases.  Modify it to fit your needs.

If any build steps are not available to you, this means you likely need to install a plugin for Jenkins.

  1. Create a Freestyle job.
  2. Create parameters for the following:
    1. SVN username (string parameter)
      SVN User
    2. SVN password (password parameter from the mask passwords plugin)
      SVN Password
    3. Version number of the tag
  3. Set the base path to your repo as an environment variable in the Jenkins jobPrepare Environment for the Run
  4.  Make sure you mask the SVN_PASS parameter
    Mask Password
  5. Add a shell build step (this is assuming Jenkins is running on a Linux server)

    1. The version tag will be consistent every time.  This allows you to put other text along with your version, such as “v” 1.0.0 or MyProject-1.0.0 depending on how you want your naming scheme.
    2. Both from and to use the BASE_PATH that we set as an environment variable.
    3. We finally do the copy using several variables we have previously defined.

Make sure the SVN package is installed on your build server.

And there you have it!  How simple is that?  Instead of having to run the command every time, you can click the “Build with Parameters” button in Jenkins, type in a few parameters, then the tags will be created the same way every time.

While this may not be very powerful, consider adding the following features (would not take that much extra effort) to make it a lot more powerful:

  • Instead of assuming we copy from the trunk, make that another parameter.  That way it can copy from anywhere to a tag.
  • Rather than forcing the user to input the version, make the argument instead point to a path within the project that holds the version file.  That way the tag automatically grabs the version from whatever is in the project.  OR make this job automatically increment the version every time!
  • Make this job run a suite of tests before the tag is created.  If the tests don’t pass, the tag isn’t created!

The options are endless… but hopefully this gives you just a taste of how powerful using automation with Jenkins can be.  Creating something like this took me maybe an hour or two.  If you invest time into learning Jenkins, it won’t take you long to create jobs like this one.  Then every time you or someone that’s much, much less experienced on your team can perform this operation by clicking a few buttons and filling out a form.

Now the next time a ‘fire’ comes and you must quickly create a new tag based on your new hot bug fix, you can just click a few buttons to create your next release tag.


  1. My output console has an error : “C:\Windows\TEMP\ line 5: svn: command not found
    Build step ‘Executar shell’ marked build as failure
    Finished: FAILURE”

    The SVN package is installed in my build server.
    Do you hava any Idea whats the problem?

    1. My guess is even though SVN is installed on your build server, it is not in the system path.

      If you have access to your build server, log into it, open a command prompt, and type “svn”. If you get an error, this confirms what I’m saying. If you don’t have access to it, get the admin to do this step.

      Add the path to the SVN executable to your system path, then open a new command prompt and try again. I think that will solve your problem.

    1. Sorry for the late response. I believe that is the case. Once you have whichever account you want to use as part of this automation, try the following manually:

      1) Create a tag with that automation user
      2) Delete that tag (assuming you don’t need it)

      If it works manually, it should work through this method.

      You can also try creating a tag from a user that doesn’t have those write privileges. My guess is it will fail.

Leave a Reply

Your email address will not be published.