2

构建工件后,我正在执行一个脚本作为构建后操作来部署工件。所以我试图读取它的构建位置。Hudson 中可用的环境变量没有给我足够的关于工件的 artifactId、Version、PackageType 的信息。

那么任何人都可以帮助我了解如何获得这些值....

提前致谢

4

3 回答 3

0

Maven 构建的所有工件都包含包含此信息的 META-INF 条目。将它们读取为 JarFile:

JarFile jf = new JarFile(path/to/artifact);
JarEntry propsEntry = jf.getJarEntry("META-INF/maven/pom.properties");
Properties props = new Properties();
props.load(jf.getInputStream(propsEntry));
// retrieve the values:
String groupId = props.get("groupId");
String artifactId = props.get("artifactId");
String version = props.get("version");
于 2011-04-26T05:01:45.360 回答
0

您可以使用http://${BUILD_URL}/job/${JOBNAME}/${BUILDNUMBER}/api/xml?xpath=//artifact/fileName/text()并将其设置为环境变量。这仅在您有 1 个工件时才有效,如果您有更多,那么您需要进行一些额外的解析。

于 2011-04-27T17:10:16.437 回答
0

我可能完全误解了你的问题,但是有没有理由不通过文件系统和WORKSPACE环境变量来获取工件,${WORKSPACE}/target/...

于 2011-04-26T17:15:00.160 回答