Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-10607

Using Global variable to get the SVN repository revision does not work properly if using more than 1 SVN repo

      If user is having more then one check out repository task then the global variable getting the revision will not work properly:

      Steps to replicate the problem:

      1. Create a new plan Configure
      2. Configure the JOB task as follow:
        • Check out task repository 1
        • Script task with the following command:
          echo ${bamboo.custom.svn.revision.number}
          
        • Check out task repository 2
          echo ${bamboo.custom.svn.revision.number}
          
      3. Save the changes and run the plan

      Build log:

      12-Jan-2012 21:58:00 	Build SIMPLEJUNIT-SIMPLEJUNIT-JOB1-6 started building on agent Default Agent
      12-Jan-2012 21:58:00 	Build working directory is C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1
      12-Jan-2012 21:58:00 	Executing build SIMPLEJUNIT-SIMPLEJUNIT-JOB1-6
      12-Jan-2012 21:58:00 	Starting task 'Source Code Checkout' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout'
      12-Jan-2012 21:58:00 	Running preRetrieveSourceCode task...
      12-Jan-2012 21:58:00 	Existing source path at 'C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1' is 'http://localhost:81/svn/simpleJUNIT/trunk' and differs from 'http://localhost:81/svn/SimpleJunitFail/trunk'
      12-Jan-2012 21:58:00 	Clean checkout enforced by repository configuration
      12-Jan-2012 21:58:00 	Cleaning build directory 'C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1'
      12-Jan-2012 21:58:01 	Updating source code to revision: 3
      12-Jan-2012 21:58:01 	Working directory 'C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1' is empty. Checking out SVN URL 'http://localhost:81/svn/SimpleJunitFail/trunk'
      12-Jan-2012 21:58:07 	Updated source code to revision: 3
      12-Jan-2012 21:58:07 	Running postRetrieveSourceCode task...
      12-Jan-2012 21:58:07 	Finished task 'Source Code Checkout'
      12-Jan-2012 21:58:07 	Running pre-build action: Build Number Stamper
      12-Jan-2012 21:58:07 	Running pre-build action: Clover Grails PreBuild Action
      12-Jan-2012 21:58:07 	Running pre-build action: VCS Version Collector
      12-Jan-2012 21:58:07 	Running pre-build action: Repository Isolation Enabler Action
      12-Jan-2012 21:58:07 	Running pre-build action: Maven Settings Prebuild Action
      12-Jan-2012 21:58:07 	
      Substituting variable: ${bamboo.custom.svn.lastchange.revision.number} with 112
      12-Jan-2012 21:58:07 	Starting task 'Script' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
      12-Jan-2012 21:58:07 	
      Beginning to execute external process for build 'SimpleJunit - SimpleJunit - Default Job'
      ... running command line:
      C:\Windows\Temp\SIMPLEJUNIT-SIMPLEJUNIT-JOB1-6-ScriptBuildTask-19061.bat
      ... in: C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1
      12-Jan-2012 21:58:07 	
      12-Jan-2012 21:58:07 	C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1>echo 112
      12-Jan-2012 21:58:07 	112
      12-Jan-2012 21:58:07 	Finished task 'Script'
      12-Jan-2012 21:58:07 	Starting task 'Checkout Default Repository' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout'
      12-Jan-2012 21:58:07 	Running preRetrieveSourceCode task...
      12-Jan-2012 21:58:07 	Existing source path at 'C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1' is 'http://localhost:81/svn/SimpleJunitFail/trunk' and differs from 'http://localhost:81/svn/simpleJUNIT/trunk'
      12-Jan-2012 21:58:07 	Clean checkout enforced by repository configuration
      12-Jan-2012 21:58:07 	Cleaning build directory 'C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1'
      12-Jan-2012 21:58:08 	Updating source code to revision: 112
      12-Jan-2012 21:58:08 	Working directory 'C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1' is empty. Checking out SVN URL 'http://localhost:81/svn/simpleJUNIT/trunk'
      12-Jan-2012 21:58:14 	Updated source code to revision: 112
      12-Jan-2012 21:58:14 	Running postRetrieveSourceCode task...
      12-Jan-2012 21:58:14 	Finished task 'Checkout Default Repository'
      12-Jan-2012 21:58:14 	
      Substituting variable: ${bamboo.custom.svn.lastchange.revision.number} with 112
      12-Jan-2012 21:58:14 	Starting task 'Script' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.script'
      12-Jan-2012 21:58:14 	
      Beginning to execute external process for build 'SimpleJunit - SimpleJunit - Default Job'
      ... running command line:
      C:\Windows\Temp\SIMPLEJUNIT-SIMPLEJUNIT-JOB1-6-ScriptBuildTask-19062.bat
      ... in: C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1
      12-Jan-2012 21:58:14 	
      12-Jan-2012 21:58:14 	C:\BambooProduct\bamboo3.4\home\xml-data\build-dir\131073\SIMPLEJUNIT-SIMPLEJUNIT-JOB1>echo 112
      12-Jan-2012 21:58:14 	112
      12-Jan-2012 21:58:14 	Finished task 'Script'
      12-Jan-2012 21:58:14 	Running post build plugin 'NCover Results Collector'
      12-Jan-2012 21:58:14 	Running post build plugin 'Clover Results Collector'
      12-Jan-2012 21:58:14 	Running post build plugin 'Artifact Copier'
      12-Jan-2012 21:58:14 	Running post build plugin 'Cleanup Build Processor'
      12-Jan-2012 21:58:14 	Finalising the build...
      12-Jan-2012 21:58:14 	Stopping timer.
      12-Jan-2012 21:58:14 	Build SIMPLEJUNIT-SIMPLEJUNIT-JOB1-6 completed.
      12-Jan-2012 21:58:14 	Running on server: post build plugin 'NCover Results Collector'
      12-Jan-2012 21:58:14 	Running on server: post build plugin 'Clover Delta Calculator'
      12-Jan-2012 21:58:14 	Running on server: post build plugin 'Build Hanging Detection Configuration'
      12-Jan-2012 21:58:14 	Running on server: post build plugin 'Maven Dependencies Postprocessor'
      12-Jan-2012 21:58:14 	All post build plugins have finished
      12-Jan-2012 21:58:14 	Generating build results summary...
      12-Jan-2012 21:58:14 	Saving build results to disk...
      12-Jan-2012 21:58:14 	Indexing build results...
      12-Jan-2012 21:58:14 	Finished building SIMPLEJUNIT-SIMPLEJUNIT-JOB1-6.
      

      SVN information:

      C:\Users\XZws>svn info http://localhost:81/svn/SimpleJunitFail/trunk/
      Path: trunk
      URL: http://localhost:81/svn/SimpleJunitFail/trunk
      Repository Root: http://localhost:81/svn/SimpleJunitFail
      Repository UUID: d28ef53e-dc8f-cb47-974a-de57de57fe66
      Revision: 3
      Node Kind: directory
      Last Changed Author: admin
      Last Changed Rev: 3
      Last Changed Date: 2011-12-29 18:59:27 +0800 (Thu, 29 Dec 2011)
      
      
      C:\Users\XZws>svn info http://localhost:81/svn/SimpleJunit/trunk/
      Path: trunk
      URL: http://localhost:81/svn/SimpleJunit/trunk
      Repository Root: http://localhost:81/svn/SimpleJunit
      Repository UUID: cd9e2243-a36b-d548-9eab-7e6566b9641d
      Revision: 112
      Node Kind: directory
      Last Changed Author: admin
      Last Changed Rev: 112
      Last Changed Date: 2012-01-04 18:57:07 +0800 (Wed, 04 Jan 2012)
      

      This also happens to repository.revision.number variable too

            [BAM-10607] Using Global variable to get the SVN repository revision does not work properly if using more than 1 SVN repo

            Monique Khairuliana (Inactive) made changes -
            Workflow Original: Bamboo Workflow 2016 v1 - Restricted [ 1441080 ] New: JAC Bug Workflow v3 [ 3382514 ]
            Status Original: Resolved [ 5 ] New: Closed [ 6 ]
            Owen made changes -
            Workflow Original: Bamboo Workflow 2016 v1 [ 1416543 ] New: Bamboo Workflow 2016 v1 - Restricted [ 1441080 ]
            Marek Went (Inactive) made changes -
            Workflow Original: Bamboo Workflow 2014 v2 [ 615122 ] New: Bamboo Workflow 2016 v1 [ 1416543 ]
            Marcin Gardias made changes -
            Resolution New: Answered [ 9 ]
            Status Original: Open [ 1 ] New: Resolved [ 5 ]

            Marcin Gardias added a comment - - edited

            Hi,
            The problem here is that the variable(s) in question date back to times when Bamboo only supported one repository in a Plan. Now that we support multiple repositories those old variable don't work quite well because of naming conflicts.

            In order to resolved that, we introduced new set of repository related variables in the format of:

            ${bamboo.planRepository.<index>.<variable>
            

            where index is position of the repo on Plan's repositories page and variable is name of variable

            for example in order to get checkout revision of second plan repository you use:

            ${bamboo.planRepository.2.revision}
            

            For the first repository of Plan (a.k.a. Default Repository) you can skip the <index> part:

            ${bamboo.planRepository.revision}
            

            is the same as:

            ${bamboo.planRepository.1.revision}
            

            Cheers
            Marcin Gardias
            Bamboo Development Team

            Marcin Gardias added a comment - - edited Hi, The problem here is that the variable(s) in question date back to times when Bamboo only supported one repository in a Plan. Now that we support multiple repositories those old variable don't work quite well because of naming conflicts. In order to resolved that, we introduced new set of repository related variables in the format of: ${bamboo.planRepository.<index>.<variable> where index is position of the repo on Plan's repositories page and variable is name of variable for example in order to get checkout revision of second plan repository you use: ${bamboo.planRepository.2.revision} For the first repository of Plan (a.k.a. Default Repository) you can skip the <index> part: ${bamboo.planRepository.revision} is the same as: ${bamboo.planRepository.1.revision} Cheers Marcin Gardias Bamboo Development Team
            James Dumay made changes -
            Workflow Original: Bamboo Workflow 2014 [ 600486 ] New: Bamboo Workflow 2014 v2 [ 615122 ]
            James Dumay made changes -
            Workflow Original: Bamboo Workflow 2010 [ 360549 ] New: Bamboo Workflow 2014 [ 600486 ]

            We've also found something similar using OnDemand.

            We have a set of build plans that run Nightly builds. Using the standard OnDemand SVN connectors, both Trunk and Branch builds end up with the same global revision number when they're triggered at midnight. This results in us having two builds displaying as having built the same revision number, but out ant build-scripts each report different revision numbers. Our IT team have been scratching their heads over this as they thought it was an issue with their Deployment application

            Matthew Hillier added a comment - We've also found something similar using OnDemand. We have a set of build plans that run Nightly builds. Using the standard OnDemand SVN connectors, both Trunk and Branch builds end up with the same global revision number when they're triggered at midnight. This results in us having two builds displaying as having built the same revision number, but out ant build-scripts each report different revision numbers. Our IT team have been scratching their heads over this as they thought it was an issue with their Deployment application

            Wow, thats great Jan! Good luck for Codegeist

            James Dumay added a comment - Wow, thats great Jan! Good luck for Codegeist

            Hello James,

            No worries, I decided to take things into my own hands and created a plug-in to get this working as I want to .

            It basically does what I described in a previous comment, you can specify a prefix per repository used in the plan which will then be added in front of the default properties used to access repository meta data.

            I entered it in Codegeist of course, please vote .
            https://marketplace.atlassian.com/manage/plugins/be.sofico.bamboo-repopropertymate-plugin

            Jan Swaelens added a comment - Hello James, No worries, I decided to take things into my own hands and created a plug-in to get this working as I want to . It basically does what I described in a previous comment, you can specify a prefix per repository used in the plan which will then be added in front of the default properties used to access repository meta data. I entered it in Codegeist of course, please vote . https://marketplace.atlassian.com/manage/plugins/be.sofico.bamboo-repopropertymate-plugin

              Unassigned Unassigned
              zyap Zed Yap [Atlassian]
              Affected customers:
              9 This affects my team
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: