如何解析Jenkins工件触发器插件输出?

时间:2019-04-20 12:04:01

标签: jenkins artifactory

我在詹金斯工作中设置了“启用Artifactory触发器”。每当工件路径中有更新时,作业将自动触发。 触发作业输出提供了触发构建的工件。 我需要解析工件并用作环境变量?

工件触发作业的詹金斯控制台日志

The build was triggered by a change in Artifactory.
The artifact which triggered the build is: http://xxx.xxx.com/artifactory/api/storage/artifactory-snapshot/ABC/exp-abc-12-5-br/abc-12-5-99-015/up-image.tgz
[EnvInject] - Loading node environment variables.
Building remotely on slave in workspace /data/engit-private-jenkins/workspace/Tools/test_artifactory_trigger
[test_artifactory_trigger] $ /bin/sh -xe /tmp/jenkins6159521155154940953.sh
+ echo 'hello world'
hello world
Finished: SUCCESS

在同一工作中,如何在上述jenkins控制台日志中访问http工件URL?我看不到它存储在环境中

1 个答案:

答案 0 :(得分:0)

我们可以使用以下命令在Artifactory中获取触发该作业的文件的URL:

environment {
RT_TRIGGER_URL = "${currentBuild.getBuildCauses('org.jfrog.hudson.trigger.ArtifactoryCause')[0]?.url}"
}

Build trigger documentation link