简体   繁体   English

Jenkins中的Shell脚本无法通过Promotion Build插件获取有关POM_VERSION / POM_ARTIFACTID的信息

[英]Shell script in Jenkins doesn't get info about POM_VERSION/POM_ARTIFACTID with Promotion Build plugin

I am trying to execute shell script with Promotion Build plugin to get info about maven properties (POM_VERSION, POM_ARTIFACTID). 我正在尝试使用Promotion Build插件执行Shell脚本,以获取有关Maven属性(POM_VERSION,POM_ARTIFACTID)的信息。

Trouble is values for Jenkins environment variables are shown, but info about maven properties are shown empty. 麻烦的是显示了Jenkins环境变量的值,但是有关maven属性的信息显示为空。 Projects where I am testing are MVN projects. 我正在测试的项目是MVN项目。

echo $POM_ARTIFACTID

echo $POM_VERSION

echo $PROMOTED_JOB_NAME
tests

echo $JOB_NAME
tests/promotion

These are the versions I am using: 这些是我正在使用的版本:

  • Jenkins 2.44 詹金斯2.44
  • Maven Project Plugin 2.14 Maven项目插件2.14
  • Promoted Builds Plugin 2.28.1 升级版插件2.28.1

Anyone knows some solution for this? 有人知道一些解决方案吗?

Edit: Adding Following Problem Statement 编辑:添加以下问题陈述

  1. Execute builds of different jobs 执行不同作业的构建
  2. In case of green ball, we want to execute a script. 如果是绿球,我们要执行一个脚本。 In this script, we do two actions: 在此脚本中,我们执行两个操作:
  3. Transferring artifact .WAR generated after correct build to another machine. 将正确构建后生成的工件.WAR转移到另一台机器上。
  4. Launch deploy in this another machine. 在另一台计算机上启动部署。

Trouble is locating path where war is generated, The WAR file has this file name format: /var/lib/jenkins/workspace/$PROMOTED_JOBNAME/target/$POM_A‌​RTIFACTID-$POM_VERS‌​ION.war so, I need info about pom_artifactID and pom_version to have path for .WAR and execute shell script. 麻烦正在查找产生战争的路径,WAR文件具有以下文件名格式:/var/lib/jenkins/workspace/$PROMOTED_JOBNAME/target/$POM_A‌RTIFACTID-$POM_VERS‌ION.war。因此,我需要有关pom_artifactID的信息和pom_version具有.WAR的路径并执行shell脚本。

POM_ARTIFACTID, POM_VERSION are not defined by promoted build plugin. 升级的构建插件未定义POM_ARTIFACTID,POM_VERSION。 For list of properties exposed, refer this . 有关公开的属性列表,请参阅this More specifically "Available Environment Variables" section. 更具体地说,“可用环境变量”部分。

POM version and artifact id are available in post build when maven plugin has run. 当运行maven插件时,POM版本和工件ID在发布后可用。 I don't think pom version are available at promote build action. 我不认为pom版本可用于促进构建操作。 See section Promotion Action 参见促进措施

From the problem statement, it looks like build pipeline plugin or multijob plugin is better fit. 从问题陈述来看,似乎更适合构建管道插件multijob插件。

More specifically, in multijob plugin you can create different phases with build, deploy as different phase which run one after the other. 更具体地说,在multijob插件中,您可以使用build创建不同的阶段,将其部署为一个不同的阶段,一个接一个地运行。 From maven job, you also pass POM version and artifactid to other project using phase parameters in post build actions. 从Maven作业中,您还可以在后期构建操作中使用阶段参数将POM版本和工件ID传递给其他项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM