Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-12621

Give the option to pass either the last changed rev or the current latest rev when triggering downstream builds.

      We are using the parameterized trigger build to kick off child builds that use the Template Project Plugin to use the same SCM configuration as the parent build.

      If the SVN revision is not passed as a parameter via parameterized-trigger the child build checks out whatever the latest revision is, even if it's newer than the parent's revision.

      If the SVN revision is passed then each child subtree is updated to the latest revision it was changed in instead of the version the parent checked out.

      Our builds include the SVN revision as part of their version and this makes the child build revision numbers not match the parent build revision, even though they are functionally the same. It would be nice to have an option to choose to pass either the revision of the last change for each checked out tree, to use the same revision as the parent build, or just always pass the revision of the parent build instead of the last changed revision.

          [JENKINS-12621] Give the option to pass either the last changed rev or the current latest rev when triggering downstream builds.

          cjo9900 added a comment -

          From what I gather here is that you want all the subtrees to checkout at a particular revision in the triggered jobs.
          From what I see below this is an issue with how the SVN plugin deals with other projects in the same repository.

          When testing on the case below I checked out r1450237 of ant and passed this info to the site job which checked out r1441816
          so the revisions were different in the two jobs.

          If you want the same revision reported in both jobs you will need pass the SVN_URL_<n>/SVN_REVISION_<n> from the parent job to the triggered jobs as a separate parameter i.e. predefined parameter PARENT_REVISION=$SVN_REVISION_<n> where n is a number used in the svn plugin. and then use that parameter in your builds for svn revision.

          Using the ant tree from apache
          http://svn.apache.org/repos/asf/ant/

          which has the following subprojects

          antlibs/
          build/
          core/
          ivy/
          sandbox/
          site/

          so assuming your parent is ant, and you want to checkout at a particular revision,
          and then in a triggered job you want to checkout the same revision of site as the parent.

          From the code in the SVN plugin which indicates that the url matching of the repos is exact [2],[3]
          and the Revision parameter action is created from the svn Tag Action in the current build [4].

          This then means that the url matching cannot occur as the repo urls are different.
          i.e. parent has http://svn.apache.org/repos/asf/ant/ in the TagAction with others not including /core repo.
          and triggered job is looking for http://svn.apache.org/repos/asf/ant/site/

          The only solution to this to alter/relax the url matching and so that if it cannot match exactly it does a best case parent matching.

          Possibly altering getRevision method or adding a new method in the RevisionParameterAction
          Example code.

          /* Gets Revision for a url or from its parent repo.*/
          public SVNRevision getRevision(String url) {
          /* To get best possible parent.

          int matchExtended = -1;
          SvnInfo bestmatch = null;
          for (SvnInfo revision: revisions) {
          if (revision.url.equals(url))

          { bestmatch = revision; break; }

          else if(url.startsWith(revision.url)) {
          int extend = url.length() - revision.url.length();
          // Is it a better match than we already have.
          if(extend < matchExtended || matchExtended == -1)

          { bestmatch = revision; matchExtended = extend; }

          }
          }
          // no exact matching items see if we have a parent repo.
          if (bestmatch != null)

          { return SVNRevision.create(bestmatch.revision); }

          return null;
          }

          [2] https://github.com/jenkinsci/subversion-plugin/blob/master/src/main/java/hudson/scm/subversion/WorkspaceUpdater.java#L174
          [3] https://github.com/jenkinsci/subversion-plugin/blob/master/src/main/java/hudson/scm/RevisionParameterAction.java#L70
          [4] https://github.com/jenkinsci/parameterized-trigger-plugin/blob/master/src/main/java/hudson/plugins/parameterizedtrigger/SubversionRevisionBuildParameters.java#L36

          cjo9900 added a comment - From what I gather here is that you want all the subtrees to checkout at a particular revision in the triggered jobs. From what I see below this is an issue with how the SVN plugin deals with other projects in the same repository. When testing on the case below I checked out r1450237 of ant and passed this info to the site job which checked out r1441816 so the revisions were different in the two jobs. If you want the same revision reported in both jobs you will need pass the SVN_URL_<n>/SVN_REVISION_<n> from the parent job to the triggered jobs as a separate parameter i.e. predefined parameter PARENT_REVISION=$SVN_REVISION_<n> where n is a number used in the svn plugin. and then use that parameter in your builds for svn revision. Using the ant tree from apache http://svn.apache.org/repos/asf/ant/ which has the following subprojects antlibs/ build/ core/ ivy/ sandbox/ site/ so assuming your parent is ant, and you want to checkout at a particular revision, and then in a triggered job you want to checkout the same revision of site as the parent. From the code in the SVN plugin which indicates that the url matching of the repos is exact [2] , [3] and the Revision parameter action is created from the svn Tag Action in the current build [4] . This then means that the url matching cannot occur as the repo urls are different. i.e. parent has http://svn.apache.org/repos/asf/ant/ in the TagAction with others not including /core repo. and triggered job is looking for http://svn.apache.org/repos/asf/ant/site/ The only solution to this to alter/relax the url matching and so that if it cannot match exactly it does a best case parent matching. Possibly altering getRevision method or adding a new method in the RevisionParameterAction Example code. /* Gets Revision for a url or from its parent repo.*/ public SVNRevision getRevision(String url) { /* To get best possible parent. if looking for http://svn.apache.org/repos/asf/ant/core/ and we have infos for http://svn.apache.org/repos/asf/ant/ http://svn.apache.org/repos/asf/ we want to return http://svn.apache.org/repos/asf/ant/ which is the best possible match */ int matchExtended = -1; SvnInfo bestmatch = null; for (SvnInfo revision: revisions) { if (revision.url.equals(url)) { bestmatch = revision; break; } else if(url.startsWith(revision.url)) { int extend = url.length() - revision.url.length(); // Is it a better match than we already have. if(extend < matchExtended || matchExtended == -1) { bestmatch = revision; matchExtended = extend; } } } // no exact matching items see if we have a parent repo. if (bestmatch != null) { return SVNRevision.create(bestmatch.revision); } return null; } [2] https://github.com/jenkinsci/subversion-plugin/blob/master/src/main/java/hudson/scm/subversion/WorkspaceUpdater.java#L174 [3] https://github.com/jenkinsci/subversion-plugin/blob/master/src/main/java/hudson/scm/RevisionParameterAction.java#L70 [4] https://github.com/jenkinsci/parameterized-trigger-plugin/blob/master/src/main/java/hudson/plugins/parameterizedtrigger/SubversionRevisionBuildParameters.java#L36

          Oleg Nenashev added a comment -

          template-project seems to be unrelated

          Oleg Nenashev added a comment - template-project seems to be unrelated

            huybrechts huybrechts
            jonathan Jonathan Stewart
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: