是否有maven构建的jenkins变量?

时间:2014-01-13 20:17:49

标签: maven jenkins

我需要访问在Jenkins运行期间通过maven构建生成的数据,然后在curl命令中使用。这最终会向机器人发送消息以在聊天室中发布。插件不是这个特定聊天客户端的选项,除非我是那个制作它们的人。任何其他能够执行curl或hit url的插件都可以,因为我可以获取数据。

目前我运行命令

mvn surefire-report:report

我能够从作业中看到这样的输出:

...
Results :

Failed tests:  
  passwordLengthRequirement(test.java.com.company.appium.suites.RegistrationTest): expected:<P[assword must be 6 characters or longer].> but was:<P[lease accept the Terms of Service].>
...
Tests in error:
  SendText(test.java.com.company.appium.suites.ChatTest): Timed out after 10 seconds waiting for presence of element located by: By.xpath: //window[2]/UIAKeyboard[1]/UIAKey[5]
...
Tests run: 40, Failures: 3, Errors: 2, Skipped: 4

[ERROR] There are test failures.

Please refer to .../target/surefire-reports for the individual test results.
[INFO] 
[INFO] <<< maven-surefire-report-plugin:2.16:report (default-cli) @ ios_junit <<<
[INFO] 
[INFO] --- maven-surefire-report-plugin:2.16:report (default-cli) @ ios_junit ---
[WARNING] Unable to locate Test Source XRef to link to - DISABLED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17:26.412s
[INFO] Finished at: Mon Jan 13 11:19:25 EST 2014
[INFO] Final Memory: 16M/81M
[INFO] ------------------------------------------------------------------------
Recording test results

如果存在可用于获取数据的变量,那将是一个巨大的帮助,但如果它们存在,我不知道它们是什么。我最近的尝试是使用 Post Build Task 插件来访问带有已完成输出的build.xml或日志文件。当尝试grep创建的build.xml并提取数据时,我需要grep因某些原因无效

XML:

`<failCount>72</failCount>`
`<skipCount>4</skipCount>`
`<totalCount>76</totalCount>`

命令:

$FAIL_COUNT=grep "failCount" ../../builds/$BUILD_NUMBER/build.xml | cut -d">" -f2,2 | cut -d"<" -f1,1

输出:

+ =grep failCount ../../builds/25/build.xml
/var/folders/2b/jv3l9cys1sqbbk6l2hxx_n1000007c/T/hudson6366869578068337646.sh: line 3: =grep: command not found

此页面有助于获取其他变量,但未列出在maven运行期间可用的内容 https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables

我最终尝试发送的消息类似于

Finished with status '$BUILD_STATUS'. Total tests run '$TOTAL_COUNT'. Total failed tests '$FAIL_COUNT'.

提前感谢任何建议。

0 个答案:

没有答案