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

List Subversion Tags parameter not available in workflow

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Using the "List Subversion tags (and more)" parameter type will not expose the parameter as a Groovy variable in a workflow.
      The "Parameters" page shows two parameters "Repository URL" and "Tag" after a run. But the parameter name I used was SVNTAG.
      Building inside a free style project seems to works: SVNTAG is defined in the environment. But the parameters page also shows "Repository URL" and "Tag", not the configured name.

      Other parameter types (e.g. Extended Choice Parameter) will be shown correctly on the Parameters page and work together with the workflow plug in.

        Attachments

          Issue Links

            Activity

            Hide
            julrich Jochen Ulrich added a comment -

            I'm experiencing a similar issue but with an inheritance project:
            I cannot use the specified parameter name "SVN_BRANCH" to trigger the project from another project. It falls back to the default value.
            The "Build with Parameters" pages shows the correct name for the parameter but the "Parameter" page displays "Tag" and "Repository URL".

            Show
            julrich Jochen Ulrich added a comment - I'm experiencing a similar issue but with an inheritance project: I cannot use the specified parameter name "SVN_BRANCH" to trigger the project from another project. It falls back to the default value. The "Build with Parameters" pages shows the correct name for the parameter but the "Parameter" page displays "Tag" and "Repository URL".
            Hide
            gordin Christoph Vogtländer added a comment - - edited

            It seems that parameters of type ListSubversionTagsParameterValue are not recorded as a groovy variable in a workflow run automatically. But it is possible to get access to the two embedded values "tag" and "tagsDir" using the following code inside a workflow run (assuming the parameter is named "SVNTAG"):

            def SVNTAG = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).getParameter("SVNTAG")
            println("Tag: ${SVNTAG.tag}, URL: ${SVNTAG.tagsDir}")
            
            Show
            gordin Christoph Vogtländer added a comment - - edited It seems that parameters of type ListSubversionTagsParameterValue are not recorded as a groovy variable in a workflow run automatically. But it is possible to get access to the two embedded values "tag" and "tagsDir" using the following code inside a workflow run (assuming the parameter is named "SVNTAG"): def SVNTAG = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).getParameter( "SVNTAG" ) println( "Tag: ${SVNTAG.tag}, URL: ${SVNTAG.tagsDir}" )
            Hide
            gek gek added a comment - - edited

            Is it actual way to get SVNTAG.tagsDir now?

            def SVNTAG = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).getParameter("SVNTAG")
            println "${SVNTAG.tagsDir}"
            

            returns null.
            Among the environment variables, there is only one containing the tag value (that early was SVNTAG.tag)

            Show
            gek gek added a comment - - edited Is it actual way to get SVNTAG.tagsDir now? def SVNTAG = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).getParameter( "SVNTAG" ) println "${SVNTAG.tagsDir}" returns null. Among the environment variables, there is only one containing the tag value (that early was SVNTAG.tag)
            Hide
            gordin Christoph Vogtländer added a comment -

            Unfortunately, SVN List Tags parameter is still not working with the "params" global variable.

            But, the code mentioned above should still work (assuming you named your parameter SVNTAG). I'm currently using a custom step which more or less does the same as the code above but is more flexible as you can simply pass the name of the parameter to the call to get the parameter:

            def call(name) {
              def listTagsParameters = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).parameters.findAll { it instanceof hudson.scm.listtagsparameter.ListSubversionTagsParameterValue }
              def p = listTagsParameters.find { it.name == name }
              // ListSubversionTagsParameterValue class is on blacklist and cannot be used in a sandboxed environment, return a map with strings resembling the relevant properties of the object
              return [name: p.name, tag: p.tag, tagsDir: p.tagsDir]
            }
            

            Add this to your custom shared library in "vars/" directory and name it e.g. svnListTagsParameter.groovy. You are then able to simply call something like this to get the parameter:

            def p = svnListTagsParameter("PARAMETER_NAME")
            println("Name: ${p.name}, Tag: ${p.tag}, Tags dir: ${p.tagsDir}")
            Show
            gordin Christoph Vogtländer added a comment - Unfortunately, SVN List Tags parameter is still not working with the "params" global variable. But, the code mentioned above should still work (assuming you named your parameter SVNTAG). I'm currently using a custom step which more or less does the same as the code above but is more flexible as you can simply pass the name of the parameter to the call to get the parameter: def call(name) { def listTagsParameters = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).parameters.findAll { it instanceof hudson.scm.listtagsparameter.ListSubversionTagsParameterValue } def p = listTagsParameters.find { it.name == name } // ListSubversionTagsParameterValue class is on blacklist and cannot be used in a sandboxed environment, return a map with strings resembling the relevant properties of the object return [name: p.name, tag: p.tag, tagsDir: p.tagsDir] } Add this to your custom shared library in "vars/" directory and name it e.g. svnListTagsParameter.groovy. You are then able to simply call something like this to get the parameter: def p = svnListTagsParameter( "PARAMETER_NAME" ) println( "Name: ${p.name}, Tag: ${p.tag}, Tags dir: ${p.tagsDir}" )
            Hide
            gek gek added a comment -

            Oh man thank you so match!

            Show
            gek gek added a comment - Oh man thank you so match!

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              gordin Christoph Vogtländer
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: