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

SVN_URL and SVN_REVISION environment variables are missing when repository url contains a variable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • RHEL5 using Jenkins ver. 1.522 with Subversion Plug-in 1.50

      When you use a repository url that contains a variable such as https://mysvn/apps/myapp/${SVN_MYAPP_BRANCH} it does not set the SVN_URL and SVN_REVISION variables. If it is set to a non variable https://mysvn/apps/myapp/trunk it works.

          [JENKINS-18714] SVN_URL and SVN_REVISION environment variables are missing when repository url contains a variable

          Luiz Casey created issue -

          SVN_URL and SVN_REVISION are missing also when "Advanced Project Options -> Use custom workspace" is set by variable.

          Jenkins ver. 1.525 with Subversion Plug-in 1.50

          Damian Klimowicz added a comment - SVN_URL and SVN_REVISION are missing also when "Advanced Project Options -> Use custom workspace" is set by variable. Jenkins ver. 1.525 with Subversion Plug-in 1.50

          I'm afraid I don't understand the issue.
          Please could you try to give me a complete scenario?
          Thanks

          Gregory Boissinot added a comment - I'm afraid I don't understand the issue. Please could you try to give me a complete scenario? Thanks

          for correct.png:

          echo SVN_REVISION=%SVN_REVISION%
          SVN_REVISION=23784
          echo SVN_REVISION_1=%SVN_REVISION_1%
          SVN_REVISION_1=23784
          echo SVN_REVISION_2=%SVN_REVISION_2%
          SVN_REVISION_2=

          for something_wrong.png:

          echo SVN_REVISION=%SVN_REVISION%
          SVN_REVISION=
          echo SVN_REVISION_1=%SVN_REVISION_1%
          SVN_REVISION_1=
          echo SVN_REVISION_2=%SVN_REVISION_2%
          SVN_REVISION_2=

          in both examples build is success!

          Damian Klimowicz added a comment - for correct.png: echo SVN_REVISION=%SVN_REVISION% SVN_REVISION=23784 echo SVN_REVISION_1=%SVN_REVISION_1% SVN_REVISION_1=23784 echo SVN_REVISION_2=%SVN_REVISION_2% SVN_REVISION_2= for something_wrong.png: echo SVN_REVISION=%SVN_REVISION% SVN_REVISION= echo SVN_REVISION_1=%SVN_REVISION_1% SVN_REVISION_1= echo SVN_REVISION_2=%SVN_REVISION_2% SVN_REVISION_2= in both examples build is success!
          Damian Klimowicz made changes -
          Attachment New: correct.png [ 24150 ]
          Attachment New: something_wrong.png [ 24151 ]

          My environment:
          Jenkins 1.525
          Jenkins Subversion Plug-in 1.50 but problem was also with version 1.44

          Damian Klimowicz added a comment - My environment: Jenkins 1.525 Jenkins Subversion Plug-in 1.50 but problem was also with version 1.44

          I am seeing this same behavior. When the definition of the "Repository URL" includes a variable, the checkout works but the SVN_REVISION and SVN_URL variables no longer get set after the checkout.

          I know the URL – I can get that from the same environment variable used to do the checkout. But it would be nice to get the revision number for build tracking.

          As the original poster said, when I specify the URL explicitly it works fine. But in may case, I want to copy jobs from one branch to another and have them run identically. So I do the copy and fill in the branch name in the SVN URL by taking part of the job title. Works fine except I lose the SVN_REVISION and SVN_URL variables from the plugin.

          Karl DeBisschop added a comment - I am seeing this same behavior. When the definition of the "Repository URL" includes a variable, the checkout works but the SVN_REVISION and SVN_URL variables no longer get set after the checkout. I know the URL – I can get that from the same environment variable used to do the checkout. But it would be nice to get the revision number for build tracking. As the original poster said, when I specify the URL explicitly it works fine. But in may case, I want to copy jobs from one branch to another and have them run identically. So I do the copy and fill in the branch name in the SVN URL by taking part of the job title. Works fine except I lose the SVN_REVISION and SVN_URL variables from the plugin.

          Daniel Beck added a comment -

          I've looked into this a few months ago, and this is what I found:

          The problem is that AbstractBuild queries (in that order) EnvironmentContributors, SCM, BuildWrapper.Environments and EnvironmentContributingActions to incrementally build the set of environment variables while a build is started.

          SubversionSCM (an SCM) looks for matching entries in the URL -> Revision map during this variable resolution. If so, they are added as SVN_URL_x and SVN_REVISION_x. Why not just add everything? My guess is externals (while listed for a build, only explicitly defined locations have corresponding variables).

          Due to the order of resolution, Env-Injected variables are not yet defined. This leads to a warning in the log of the form:

          WARNING hudson.scm.SubversionSCM buildEnvVars
          no revision found corresponding to ${SVNURL}; known: [https://svn/repo/...]

          Afterwards, when the URLs are getting checked out, the variables have already been defined, therefore that works.

          Daniel Beck added a comment - I've looked into this a few months ago, and this is what I found: The problem is that AbstractBuild queries (in that order) EnvironmentContributors, SCM, BuildWrapper.Environments and EnvironmentContributingActions to incrementally build the set of environment variables while a build is started. SubversionSCM (an SCM) looks for matching entries in the URL -> Revision map during this variable resolution. If so, they are added as SVN_URL_x and SVN_REVISION_x. Why not just add everything? My guess is externals (while listed for a build, only explicitly defined locations have corresponding variables). Due to the order of resolution, Env-Injected variables are not yet defined. This leads to a warning in the log of the form: WARNING hudson.scm.SubversionSCM buildEnvVars no revision found corresponding to ${SVNURL}; known: [https://svn/repo/...] Afterwards, when the URLs are getting checked out, the variables have already been defined, therefore that works.
          Manuel Recena Soto made changes -
          Assignee Original: Gregory Boissinot [ gbois ] New: Manuel Recena Soto [ recena ]
          Manuel Recena Soto made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

            recena Manuel Recena Soto
            lcasey Luiz Casey
            Votes:
            7 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: