Subversion Release Manager

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID svn-release-mgr Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Dependencies
1.2
Nov 03, 2010
1.318
subversion (version:1.20)
Source Code
Issue Tracking
Maintainer(s)
Subversion
Open Issues
n/a (id: mindless)
Usage Installations 2013-Apr 1929
2013-May 1973
2013-Jun 1916
2013-Jul 1959
2013-Aug 1884
2013-Sep 1935
2013-Oct 1921
2013-Nov 1936
2013-Dec 1896
2014-Jan 2025
2014-Feb 2010
2014-Mar 2035

This plugin allows you to set up a job in Jenkins for building specific revisions of a project.
Be sure to select both "Use Subversion Release Manager" in the top section of the job configuration page, and select "Subversion Release" for the SCM type, rather than the standard Subversion SCM.

Here is a screenshot of this project configured to use the plugin.

Today it uses a copy of SubversionSCM named SubversionReleaseSCM, but would only require a small change to SubversionSCM.CheckOutTask to work with the core code.

Here is the change that is needed. Just look for the java comments that start with EDIT.

  1. Add a String field for the revision
  2. In the constructor, retrieve the revision number from the environment variable.
  3. Set the revision to check out based on the value stored in revision field if not null
    Here is a link to the patch request: issue #3207
SubversionSCM.java CheckOutTask
    /**
     * Either run "svn co" or "svn up" equivalent.
     */
    private static class CheckOutTask implements FileCallable<List<External>> {
        private final ISVNAuthenticationProvider authProvider;
        private final Date timestamp;
        // true to "svn update", false to "svn checkout".
        private boolean update;
        private final TaskListener listener;
        private final ModuleLocation[] locations;
        //EDIT (1) next line added by piascikj for building specific revision
        private String revision;

        public CheckOutTask(AbstractBuild<?, ?> build, SubversionSCM parent, Date timestamp, boolean update, TaskListener listener) {
            this.authProvider = parent.getDescriptor().createAuthenticationProvider();
            this.timestamp = timestamp;
            this.update = update;
            this.listener = listener;
            this.locations = parent.getLocations(build);
            //EDIT (2) next line added by piascikj for building specific revision
            this.revision = build.getEnvVars().get("REVISION");
        }

        public List<External> invoke(File ws, VirtualChannel channel) throws IOException {
            final SVNClientManager manager = createSvnClientManager(authProvider);
            try {
                final SVNUpdateClient svnuc = manager.getUpdateClient();
                final List<External> externals = new ArrayList<External>(); // store discovered externals to here
                //EDIT next line removed by piascikj for building specific revision
                //final SVNRevision revision = SVNRevision.create(timestamp);
                //EDIT (3) next 6 lines added by piascikj for building specific revision
                SVNRevision revision = SVNRevision.create(timestamp);
                try {
                	if (this.revision != null) revision = SVNRevision.create(Long.parseLong(this.revision));
                } catch (NumberFormatException e) {
                	listener.getLogger().println("Unable to parse revision number from value: " + this.revision + ", checking out HEAD revision.");
                }
                if(update) {
                    for (final ModuleLocation l : locations) {
                        try {
                            listener.getLogger().println("Updating "+ l.remote);

                            File local = new File(ws, l.local);
                            svnuc.setEventHandler(new SubversionUpdateEventHandler(listener.getLogger(), externals,local,l.local));
                            svnuc.doUpdate(local.getCanonicalFile(), l.getRevision(revision), true);

                        } catch (final SVNException e) {
                            if(e.getErrorMessage().getErrorCode()== SVNErrorCode.WC_LOCKED) {
                                // work space locked. try fresh check out
                                listener.getLogger().println("Workspace appear to be locked, so getting a fresh workspace");
                                update = false;
                                return invoke(ws,channel);
                            }
                            if(e.getErrorMessage().getErrorCode()== SVNErrorCode.WC_OBSTRUCTED_UPDATE) {
                                // JENKINS-1882. If existence of local files cause an update to fail,
                                // revert to fresh check out
                                listener.getLogger().println(e.getMessage()); // show why this happened. Sometimes this is caused by having a build artifact in the repository.
                                listener.getLogger().println("Updated failed due to local files. Getting a fresh workspace");
                                update = false;
                                return invoke(ws,channel);
                            }

                            e.printStackTrace(listener.error("Failed to update "+l.remote));
                            // trouble-shooting probe for #591
                            if(e.getErrorMessage().getErrorCode()== SVNErrorCode.WC_NOT_LOCKED) {
                                listener.getLogger().println("Polled jobs are "+ Hudson.getInstance().getDescriptorByType(SCMTrigger.DescriptorImpl.class).getItemsBeingPolled());
                            }
                            return null;
                        }
                    }
                } else {
                    Util.deleteContentsRecursive(ws);

                    // buffer the output by a separate thread so that the update operation
                    // won't be blocked by the remoting of the data
                    PipedOutputStream pos = new PipedOutputStream();
                    StreamCopyThread sct = new StreamCopyThread("svn log copier", new PipedInputStream(pos), listener.getLogger());
                    sct.start();

                    for (final ModuleLocation l : locations) {
                        try {
                            listener.getLogger().println("Checking out "+l.remote);

                            File local = new File(ws, l.local);
                            svnuc.setEventHandler(new SubversionUpdateEventHandler(new PrintStream(pos), externals, local, l.local));
                            svnuc.doCheckout(l.getSVNURL(), local.getCanonicalFile(), SVNRevision.HEAD, l.getRevision(revision), true);
                        } catch (SVNException e) {
                            e.printStackTrace(listener.error("Failed to check out "+l.remote));
                            return null;
                        }
                    }

                    pos.close();
                    try {
						sct.join(); // wait for all data to be piped.
					} catch (InterruptedException e) {
                        throw new IOException2("interrupted",e);
                    }
                }

                try {
                    for (final ModuleLocation l : locations) {
                        SVNDirEntry dir = manager.createRepository(l.getSVNURL(),true).info("/",-1);
                        if(dir!=null) {// I don't think this can ever be null, but be defensive
                            if(dir.getDate()!=null && dir.getDate().after(new Date())) // see http://www.nabble.com/NullPointerException-in-SVN-Checkout-Update-td21609781.html that reported this being null.
                                listener.getLogger().println(Messages.SubversionSCM_ClockOutOfSync());
                        }
                    }
                } catch (SVNException e) {
                    LOGGER.log(Level.INFO,"Failed to estimate the remote time stamp",e);
                }

                return externals;
            } finally {
                manager.dispose();
            }
        }

        private static final long serialVersionUID = 1L;
    }

Change Log

Version 1.2 (2010-11-03)
  • Fix a couple help links
Version 1.1 (2010-03-01)
  • Thread safety fix for compare and build actions
  • Change maxRevisions field validation to client-side
  • Fix help link and add content
  • Misc cleanup and javadoc updates
  • Bump version up to 1.1 since there's a 1.0 out there even though 0.2 was the last release
Version 0.2 (2009-12-29)
  • Fix broken image
  • Update uses of deprecated APIs
Version 0.1 (2009-03-27)
  • Initial release

Labels

plugin-scm-related plugin-scm-related Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jan 22, 2010

    Jay Blanton says:

    Can you explain if this revision is the Subversion revision or is this related t...

    Can you explain if this revision is the Subversion revision or is this related to a tag/branch in subversion?

    I installed this plugin and don't see the releases link.

    Is that because I need to make code changes suggested above?

    Thanks...jay

  2. Apr 23, 2010

    John Carter says:

    Note that the example screenshot has a typo - "Prodution" should be "Production"

    Note that the example screenshot has a typo - "Prodution" should be "Production"

  3. Jun 19, 2010

    Krishnan says:

    Hi I am supposed to build a svn revision using subversion release manager. I ha...

    Hi

    I am supposed to build a svn revision using subversion release manager. I have configured a build parameter for the revision number. I would like to set a default value so that SVN head is built when the revision number is not specified/changed. 'HEAD' does not seem to be working. I see the following error:

    Location 'http://<mySVNLocation>/trunk@HEAD' does not exist.

    any workarounds? Thanks.

  4. Jun 28, 2010

    Salman Awan says:

    Hey Jesse, Great plug-in, worked a charm, thanks a lot as it resolved a pressing...

    Hey Jesse, Great plug-in, worked a charm, thanks a lot as it resolved a pressing issue on my part.

    Just a question, when selecting 'Subversion Release' instead of 'Subversion' as SCM, two additional options that are available with 'Subversion' SCM are not available any more i.e. 'Use update' and 'Revert'.

    Is that by design, or you might consider adding them in future?

    Thanks again, Regards, Salman Awan

  5. Jul 30, 2010

    robertredd - says:

    In addition to the issue mentioned by Salman above, I can also no longer browse ...

    In addition to the issue mentioned by Salman above, I can also no longer browse or see the diff in files modified when looking at the project's change history using the Repository Browser option.  I use ViewSVN with the repository URL specified.  It worked when the SCM was the original Subversion type, though.

  6. Aug 04, 2010

    Frank Keller says:

    Hi, this is a nice and very usefull plugin, but i have one problem. I have a jo...

    Hi,

    this is a nice and very usefull plugin, but i have one problem. I have a job with additional parameters for environments, this paramter is ignored from the plugin when building a release from the release overview. is there

    a way to use release manager and seperatly configured parameters?

    thx

  7. Aug 16, 2010

    korpo - says:

    Hello, Jesse. I saw that you largely replaced Subversion SCM plugin for this an...

    Hello, Jesse.

    I saw that you largely replaced Subversion SCM plugin for this and had some trouble because you use your classes instead of installed ones. I see you do this because you want to be able to use a specific revision upon checkout.

    Reading the trunk sources of the "subversion" SCM plugin I saw that you can now add a "RevisionParameterAction" that will override the Revision to be checked out in the CheckOutTask. This might make your fix obsolete. I'll try if I can get a version together that uses this mechanism - I just need a way to construct a SVNRevision object in the doBuild action and then I can add this parameter to the build to be scheduled in your doBuild() method.

    Cheers

    1. Aug 17, 2010

      korpo - says:

      I tested it, it works fine with the RevisionParameterAction. I'm just fiddling w...

      I tested it, it works fine with the RevisionParameterAction. I'm just fiddling with the doBuild() and the associated stapled form, but the code can work with the given SubversionSCM and the plugin is then very lean.

      Cheers

  8. Aug 18, 2010

    korpo - says:

    Hello, Jesse. I have a finished version here that just uses the regular subvers...

    Hello, Jesse.

    I have a finished version here that just uses the regular subversion plugin plus your few extra files and it works fine. How do I commit it back to you?

    Cheers

    1. Oct 22, 2010

      Dan Fuller says:

      Hi Oliver Any word on the update?  If you're unable to update this plugin,...

      Hi Oliver

      Any word on the update?  If you're unable to update this plugin, any change of submitting an alternative?

      Regards,

      Dan

      1. Oct 26, 2010

        korpo - says:

        Yes, maybe that's the way to go. I just hoped we could fix it here. We have my ...

        Yes, maybe that's the way to go. I just hoped we could fix it here.

        We have my fix in use. It really makes it nice and clean, and the subversion maintenance is left to the subversion plugin.

        We find this plugin useful.

        Cheers,

        Oliver

  9. Oct 27, 2010

    Michael Bender says:

    Oliver, I'd love to have your fix too. When install this version and try to run ...

    Oliver, I'd love to have your fix too. When install this version and try to run I get the following error. Any idea why this might be happening?At revision 2098
    hudson.util.IOException2: revision check failed on https://infusedindustries.springloops.com/source/infusedpalermo/trunk/esofthead/php
    at hudson.scm.SubversionReleaseChangeLogBuilder.buildModule(SubversionReleaseChangeLogBuilder.java:133)
    at hudson.scm.SubversionReleaseChangeLogBuilder.run(SubversionReleaseChangeLogBuilder.java:75)
    at hudson.scm.SubversionReleaseSCM.calcChangeLog(SubversionReleaseSCM.java:276)
    at hudson.scm.SubversionReleaseSCM.checkout(SubversionReleaseSCM.java:376)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1038)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:479)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:411)
    at hudson.model.Run.run(Run.java:1257)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:129)
    Caused by: org.tmatesoft.svn.core.SVNException: svn: No such revision 2100
    svn: REPORT of '/source/infusedpalermo/!svn/bc/2099/trunk/esofthead/php': 500 Internal Server Error (https://infusedindustries.springloops.com)

    1. Dec 06, 2010

      korpo - says:

      Hello, all. Please help me out. I could provide a version that uses the subver...

      Hello, all.

      Please help me out.

      I could provide a version that uses the subversion plugin for Hudson, so that the normal subversion plugin can be used again as SCM plugin.

      What would be the best way to release it back to this website? The original contributor of this plugin has not responded, and I would like to share it.

      My only problem is how. Can anyone of you either walk me through the bugfix process or through the process of registering a plugin?

      Thank you,

      Oliver

  10. Dec 11, 2010

    wwDevil says:

    Hi Oliver. Why Subversion Release Manager skip 'This build requires parameters:'...

    Hi Oliver.
    Why Subversion Release Manager skip 'This build requires parameters:' page when i click build link(for example: http://localhost:8080/job/test/releases/build?revision=3) in releases page? This page is displayed when i click build link(for example: http://localhost:8080/job/test/build?delay=0sec) in jobs list page.

  11. Apr 07, 2011

    Tomasz Melcer says:

    It would be nice to have svn external definitions also reverted to same revision...

    It would be nice to have svn external definitions also reverted to same revision. I currently use a one-liner as a shell build step:

    svn up -r 1234; svn status | grep ^X | cut -c9 | xargs -L1 svn up -r 1234
    
  12. Apr 22, 2011

    Jim Searle says:

    The issue mentioned in the original description is still not fixed in this plugi...

    The issue mentioned in the original description is still not fixed in this plugin?

    http://issues.jenkins-ci.org/browse/JENKINS-3207

    Even though "korpo" says they have a fix to submit back?  Is the original author gone?

  13. Dec 17, 2012

    vijayaragavan soundararajan says:

    Every time the source code is checked out and not updated. Can i know how can I ...

    Every time the source code is checked out and not updated. Can i know how can I just update the sources?

    I tried with a boolean paramertization too. but i am not sure i have done correctly that. Please let me know what should i use it Boolean Value :  field.

    Thanks a ton.

    Vijay S