Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get svn version number from checkout for use in dsl

I created a pipeline job and would like to get the svn version number to enable further downstream processing in a call to a shell script. I am using a pipeline script similar to the following:

node {
   // Mark the code checkout 'stage'....
   stage 'Checkout'

   // Get some code from a SVM repository
   checkout(
       [
           $class: 'SubversionSCM', 
           additionalCredentials: [], 
           excludedCommitMessages: '', 
           excludedRegions: '', 
           excludedRevprop: '', 
           excludedUsers: '', 
           filterChangelog: false, 
           ignoreDirPropChanges: false, 
           includedRegions: '', 
           locations: [
               [
                   ...
                ]
            ], 
            workspaceUpdater: [$class: 'UpdateUpdater']
        ]
    )
    def svnversionnumber=${SVN_VERSION}



   sh "/.../someshellscript ${svnversionnumber};"
}

Is there documentation on the checkout function available? Is it possible to get hold of the svn revision number? I can see that the revision is output to the log.

like image 556
sweetfeet Avatar asked Aug 25 '16 03:08

sweetfeet


People also ask

How do I find my svn revision number?

"svn info --show-item revision" will give the current revision to which the current directory is updated.

How do I checkout a specific version of svn?

If you want to write a script which requires no input, you should use the official Subversion command line client instead. checkout a working copy in REV revision: svn checkout --revision REV https://svn.example.com/svn/MyRepo/trunk/ svn checkout https://svn.example.com/svn/MyRepo/trunk/@REV.

How do I get latest version of svn?

Simply type svn update [name-of-directory] , or cd to that directory and type svn update there.

What is svn revision?

Subversion, with the command line tool svn, is a revision control system, also known as a source code management system (scm) or a source code control system (sccs). The subversion server maintains a repository, where files are stored in a hierarchy of folders, same as a traditional file system.


1 Answers

I had the same issue, but you can solve it by using the map that is returned from calling SCM checkout. It contains a value for SVN_REVISION.

// Get some code from a SVM repository
def scmVars = checkout(
  ...
)

def svnversionnumber = scmVars.SVN_REVISION
like image 77
tchambers Avatar answered Sep 21 '22 20:09

tchambers