How to check out subversion to a specific revision?

Article ID:227153787
2 minute readKnowledge base

Issue

  • I would like to checkout a project to a specific SVN revision

  • I would like to checkout a project to a specific branch or tag

Environment

  • CloudBees Jenkins Enterprise (CJE)

  • Subversion Plugin

Resolution

Specify the subversion repository URL to check out, such as "https://svn.apache.org/repos/asf/ant/". You can also add "@NNN" at the end of the URL to check out a specific revision number, if that’s desirable.

Key concepts:

  • Revision numbers in Subversion are pretty straightforward—​integers that keep getting larger as you commit more changes to your versioned data.

  • Subversion has no internal concept of a branch or tag, it knows only how to make copies. When you copy a directory, the resultant directory is only a branch or tag because you attach that meaning to it. Branch or tag is just an ordinary directory that happens to carry some extra historical information. Subversion’s Branch or tag exists as normal filesystem directories in the repository. The location of the directory doesn’t matter to Subversion. Most teams follow a convention of putting all branches into a "/branches" or "/tags" directory, but you’re free to invent any policy you wish.

Example

On the Terminal

After creating a SVN repo a "svn_demo_repository_url", a development team start working on it.

1. Revision 1: Checking out a working copy from a remote repository

Input:

svn checkout svn_demo_repository_url

Output:

A crl_demorepo/trunk A crl_demorepo/branches A crl_demorepo/tags Checked out revision 1.

2. Revision 2: Creating first file (README.md)

After creating file, the status of the repo is checked

Input:

svn status -u

Output:

? trunk/README.md Status against revision: 1

Then, trunk/README.md is added to be tracked

Input:

svn add trunk/README.md

Output:

A trunk/README.md

Finally, the change is committed

Input:

svn commit trunk/README.md

Output:

Adding trunk/README.md Transmitting file data . Committed revision 2.

revision has increased a number.

Revision N: N committed changes from your working copy and other workmates' against the remote repository. Remarking that svn update will be necessary to sync with your workmates.

…​

Output:

…​ Transmitting file data . Committed revision N.

3. Creating branches

A new branch is created

Input:

svn copy svn_demo_repository_url/trunk svn_demo_repository_url/branches/feat-1 -m "Creating a private branch of feat-1"

Output:

Committed revision 7.

Then, a copy of the README.md file is a created. After that, status is checked:

svn status -u

Output:

* branches/feat-1/README_copy.md * branches/feat-1/README.md * branches/feat-1 * 1 branches Status against revision: 8

On Jenkins

Go to the Job you would like to checkout a project to a specific SVN revision > Source Code Management > Subversion > Repository URL.

Case A: Checking out to the "revision 3" of the "trunk"

Introduce: "svn_demo_repository_url"

The console build output would print something similar to this:

Started by user ...
Building remotely on ... in workspace ...
Checking out a fresh workspace because there's no workspace at ...
Cleaning local Directory .
Checking out svn_demo_repository_url/trunk at revision 3
A         README.md
At revision 3

...
Finished: SUCCESS
Case B: Checking out to the "latest revision" of the "branch feat-1"

Introduce: "svn_demo_repository_url/branches/feat-1"

The console build output would print something similar to this:

Started by user ...
Building remotely on ... in workspace ...
Switching from svn_demo_repository_url/trunk to svn_demo_repository_url/branches/feat-1
Switching to svn_demo_repository_url/branches/feat-1 at revision '2016-09-13T16:15:58.792 +0000'
A         README_copy.md
U         README.md
At revision 8

...
Finished: SUCCESS