Jenkins用于运行作业的完整工作空间链接-指向我的作业创建的屏幕截图的链接

y0u0uwnf  于 2022-10-06  发布在  Jenkins
关注(0)|答案(0)|浏览(163)

运行Jenkins ver. 2.150.1

我有一个脚本,它记录在运行单元测试时生成的文件的URL。这是一个生成的文件,我希望在日志文件中将有效URL打印到该文件。

作业名为test-staging,管道分支为level0,内部版本号为3,当我调用System.getenv("BUILD_URL")时,我得到以下结果:

http://jenkins.mydomain/job/test-staging/job/level0/3

我要链接的文件是screenshot目录中的工作区,如果我通过Jenkins浏览到它,我会得到:

http://jenkins.mydomain/job/test-staging/job/level0/3/execution/node/3/ws/screenshot/error1.png

因此,位置是BUILD_URL + 'execution/node/3/ws/' + screenshotLocation

我如何获得“节点编号”或这里的3代表什么?我在环境变量中看不到它(我在测试中这样做):

for(Map.Entry<String, String> me : System.getenv().entrySet()){
            log.info("  Environment Dump - var {} :: {}", me.getKey(), me.getValue());
}

上面的输出是:

10:13:22 INFO  -   Environment Dump - var JAVA_HOME :: /home/dev/jdk
10:13:22 INFO  -   Environment Dump - var MAVEN_PROJECTBASEDIR :: /home/dev/project
10:13:22 INFO  -   Environment Dump - var OLDPWD :: /home/dev/project
10:13:22 INFO  -   Environment Dump - var TERM :: xterm
10:13:22 INFO  -   Environment Dump - var BUILD_NUMBER :: 3
10:13:22 INFO  -   Environment Dump - var HOSTNAME :: a80e5d3525ef
10:13:22 INFO  -   Environment Dump - var BUILD_URL :: http://jenkins.mydomain/job/test-staging/job/level0/3
10:13:22 INFO  -   Environment Dump - var M2_HOME :: /home/dev/apache-maven-3.5.4
10:13:22 INFO  -   Environment Dump - var _JAVA_OPTIONS :: -Dawt.useSystemAAFontSettings=on -Dsun.java2d.xrender=true
10:13:22 INFO  -   Environment Dump - var PWD :: /home/dev/project
10:13:22 INFO  -   Environment Dump - var SHLVL :: 1
10:13:22 INFO  -   Environment Dump - var HOME :: /home/dev
10:13:22 INFO  -   Environment Dump - var MAVEN_CMD_LINE_ARGS ::  -Dsonar.host.url=http://sonar:9000 clean compile -

如何确定此处工作空间的位置?尤其是/node/3中的3?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题