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

Maven metadata plugin does not work with jenkins pipeline

      Maven metadata plugin does not work with jenkins pipeline

      env vars are never set

          [JENKINS-38619] Maven metadata plugin does not work with jenkins pipeline

          Mark McKenna created issue -

          Workaround to access the properties anyway:

          ...
          // currently not possible, so workaround used:
          // String version = params.COMPONENT_VERSION
          String version = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).getParameter("COMPONENT").version
          ...
          

          Torsten Reinhard added a comment - Workaround to access the properties anyway: ... // currently not possible, so workaround used: // String version = params.COMPONENT_VERSION String version = currentBuild.rawBuild.getAction(hudson.model.ParametersAction).getParameter( "COMPONENT" ).version ...

          improvement to get it working, even if "COMPONENT_VERSION" will be passed as String parameter from an upstream project:

          String getVersion( String parameterName ) {
              def action = currentBuild.rawBuild.getAction(hudson.model.ParametersAction)
          
              // try to get the value directly if passed as String from an upstream job    
              StringParameterValue passed = (StringParameterValue)action.getParameter("${parameterName}_VERSION")
              if( passed != null ) {
                  return passed.getValue()        
              }
              
              // get the version property directly from Maven MetaDataPlugin
              return action.getParameter(parameterName).version
          }
          

          Torsten Reinhard added a comment - improvement to get it working, even if "COMPONENT_VERSION" will be passed as String parameter from an upstream project: String getVersion( String parameterName ) { def action = currentBuild.rawBuild.getAction(hudson.model.ParametersAction) // try to get the value directly if passed as String from an upstream job StringParameterValue passed = (StringParameterValue)action.getParameter( "${parameterName}_VERSION" ) if ( passed != null ) { return passed.getValue() } // get the version property directly from Maven MetaDataPlugin return action.getParameter(parameterName).version }
          Torsten Reinhard made changes -
          Link New: This issue relates to JENKINS-45566 [ JENKINS-45566 ]

          Hi,

          I submitted a PR to fix that bug : see https://github.com/jenkinsci/maven-metadata-plugin/pull/13 

          P.S. : torstenreinhard's work-around did not work for me (action was null).

          Benjamin BONNET added a comment - Hi, I submitted a PR to fix that bug : see https://github.com/jenkinsci/maven-metadata-plugin/pull/13   P.S. :  torstenreinhard 's work-around did not work for me (action was null).
          Marc Rohlfs made changes -
          Link New: This issue depends on JENKINS-38978 [ JENKINS-38978 ]
          Marc Rohlfs made changes -
          Assignee Original: Gesh Markov [ gesh ] New: Benjamin BONNET [ bbonnet ]
          Marc Rohlfs made changes -
          Remote Link New: This issue links to "Pull Request 13 (Web Link)" [ 19745 ]
          Marc Rohlfs made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Marc Rohlfs made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

            marcrohlfs Marc Rohlfs
            m4rkmckenna Mark McKenna
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: