Details

    • Similar Issues:

      Description

      Hi,

      Would be nice if plugin has possibility to read xml using xpath, this might be useful for reading version from maven pom.xml it might look like:
      ${PROPFILE,file="somepath/pom.xml",xpath="/project/version/text()"}

      Regards
      Eugene Gligalov

        Attachments

          Activity

          Hide
          jaker82 Eugene Gligalov added a comment -

          or even better:
          ${XML,file="somepath/pom.xml",xpath="/project/version/text()"}

          Show
          jaker82 Eugene Gligalov added a comment - or even better: ${XML,file="somepath/pom.xml",xpath="/project/version/text()"}
          Hide
          joshua_niehus Joshua Niehus added a comment - - edited

          I extended the token macro plugin on my fork to include this:
          https://github.com/jniehus/token-macro-plugin

          Im sure I violated many laws from the Kingdom of nouns but it seems to work. Use as requested:
          ${XML, file="pom.xml", xpath="/project/version/text()"} -> 1.6-SNAPSHOT

          I dont like to kill jobs for simple mistakes or in cases where to token value is used in a trivial way so I passed off most of the errors into the token's string.
          *For example, the token will read 'XML not well formed' on files where the xml is missing a node/endNode.
          *In the event your xpath expression catches more that one value, the token string will become a semicolon separated string of all the values...
          *For erroneous xpath expressions, i set the token to read as 'Error reading <filename>. <xpathExpression> is probably messed up'.

          Show
          joshua_niehus Joshua Niehus added a comment - - edited I extended the token macro plugin on my fork to include this: https://github.com/jniehus/token-macro-plugin Im sure I violated many laws from the Kingdom of nouns but it seems to work. Use as requested: ${XML, file="pom.xml", xpath="/project/version/text()"} -> 1.6-SNAPSHOT I dont like to kill jobs for simple mistakes or in cases where to token value is used in a trivial way so I passed off most of the errors into the token's string. *For example, the token will read 'XML not well formed' on files where the xml is missing a node/endNode. *In the event your xpath expression catches more that one value, the token string will become a semicolon separated string of all the values... *For erroneous xpath expressions, i set the token to read as 'Error reading <filename>. <xpathExpression> is probably messed up'.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Alex Earl
          Path:
          .gitignore
          src/main/java/org/jenkinsci/plugins/tokenmacro/impl/XmlFileMacro.java
          src/test/java/org/jenkinsci/plugins/tokenmacro/impl/XmlFileMacroTest.java
          http://jenkins-ci.org/commit/token-macro-plugin/c6d4ae5c5a6d3d03f2a575029c23ea3fbd7bc155
          Log:
          Fix JENKINS-12742

          Added new XML macro based on joshua_niehus's tree

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: .gitignore src/main/java/org/jenkinsci/plugins/tokenmacro/impl/XmlFileMacro.java src/test/java/org/jenkinsci/plugins/tokenmacro/impl/XmlFileMacroTest.java http://jenkins-ci.org/commit/token-macro-plugin/c6d4ae5c5a6d3d03f2a575029c23ea3fbd7bc155 Log: Fix JENKINS-12742 Added new XML macro based on joshua_niehus's tree
          Hide
          slide_o_mix Alex Earl added a comment -

          Will be in next release.

          Show
          slide_o_mix Alex Earl added a comment - Will be in next release.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Christopher Orr
          Path:
          src/main/resources/org/jenkinsci/plugins/tokenmacro/impl/XmlFileMacro/help.jelly
          http://jenkins-ci.org/commit/token-macro-plugin/83197bd18edd7b2a78e124c66c142313cea991bc
          Log:
          JENKINS-12742 Add help text for XML macro.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christopher Orr Path: src/main/resources/org/jenkinsci/plugins/tokenmacro/impl/XmlFileMacro/help.jelly http://jenkins-ci.org/commit/token-macro-plugin/83197bd18edd7b2a78e124c66c142313cea991bc Log: JENKINS-12742 Add help text for XML macro.

            People

            • Assignee:
              slide_o_mix Alex Earl
              Reporter:
              jaker82 Eugene Gligalov
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: