Get Maven artifact properties from Jenkins plugin

瘦欲@ 提交于 2019-12-11 03:12:10

问题


I have a Jenkins and a Sonar installation, for which I'm writing a Jenkins plugin that acts after any Maven project is built and asks Sonar for that specific project's metrics. For this, I'm trying to get the Maven groupId and artifactId from the Jenkins plugin and parametrize a Sonar web API request with them.

I'm currently using the perform(AbstractBuild build, Launcher launcher, BuildListener listener) extension point, but I can't seem to find the relevant attributes in the build object.

I have found a few questions that could relate to this problem:

  • project version from maven to sonar using hudson
  • maven picking up environment variable set by jenkins
  • Getting Maven Version in Jenkins

But all of these either use Groovy, that I'd rather avoid, and/or use environment variables, that I had no luck with. Specifically, I have added the following code to the pom.xml:

<jenkins.groupId>${env.POM_GROUPID}</jenkins.groupId>

and used this code in the plugin:

info.append("Jenkins groupId: " + System.getProperty("jenkins.groupId") + "\n");

This outputs "Jenkins groupId: null"

I'll be glad for any pointers, even in radically other directions.

来源:https://stackoverflow.com/questions/26885175/get-maven-artifact-properties-from-jenkins-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!