首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以在Jenkins仪表板中突出显示跳过的测试吗?

我可以在Jenkins仪表板中突出显示跳过的测试吗?
EN

Stack Overflow用户
提问于 2013-03-19 01:13:58
回答 1查看 362关注 0票数 2

我在Jenkins中有一个正在测试的项目(“测试安装”;它会进行一些回归测试来验证安装程序是否正常工作)。这个项目对Jenkins控制之外的东西有一个软依赖:如果最新的安装程序不可用,那么我们就不能测试它。不过,我们总是可以重新测试旧的安装程序,这似乎是值得做的(我们有CPU周期,所以我们也可以烧掉它们)。

我想要的是,如果安装程序不是最新的,就发出一个响亮的警告,然后继续测试。

我尝试的第一件事是做了一个在安装程序过期时失败的测试。这一点很突出,但令人困惑,因为安装测试实际上并不是失败的东西。

现在我有了相同的测试,但它使用了JUnit假设而不是断言,这意味着测试要么跳过,要么通过。这也不太完美,因为Jenkins在首页报告了"9个测试,0个失败“,只有当我深入到测试结果的多个层次时,我才看到9个测试中的1个被跳过了。

我可以让Jenkins在首页上报告跳过的测试吗?我没有找到适合它的插件。有没有更好的方法来警告安装程序已过期?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-08 00:09:47

回答你的问题有点晚了,但可能会对其他人有所帮助。。。

两件非常简单的事情,我认为在这样的情况下最有效:

  • 添加了一个额外的测试来检查最新的安装程序版本,但失败了。因此该作业将被标记为不稳定。
  • ,或者您可以使用某个构建后插件来检查日志,并将作业标记为失败而不是不稳定。

没有一种简单的方法可以使跳过的测试更加突出。

但是你可以对测试结果做一些后处理。

我们在作业脚本/测试脚本中生成一个VERSION.txt文件,并将其放入作业工作区。然后,我们使用Groovy Postbuild操作并设置作业描述:

"Groovy后期构建“

代码语言:javascript
复制
def currentBuild = Thread.currentThread().executable
def ws = manager.build.workspace.getRemote()
String desc = new File(ws + "/VERSION.txt").text
currentBuild.setDescription(desc)

这非常有用,我们可以在作业历史记录中查看测试的版本或其他详细信息。

为了更突出地标记事物。。。>;)你可以使用徽章和一些时髦的东西。

使用的插件:

https://wiki.jenkins.io/display/JENKINS/Groovy+Postbuild+Plugin

Groovy Postbuild插件是唯一真正需要的插件。Groovy是THe构建后插件的一部分。

https://wiki.jenkins.io/display/JENKINS/Groovy+plugin

groovy插件在试验Groovy或使用groovy创建作业时非常有用。

https://wiki.jenkins.io/display/JENKINS/Build+Trigger+Badge+Plugin

实际上,这些徽章可以在jenkins groovy postbuild插件中找到。如果使用了各种触发器,但实际上不需要设置徽章,那么我使用的BuildTriggerBadge插件是很有用的。我在这里包含了它,因为它是安装的,我不能100%确定我的代码在没有它的情况下是否可以工作(但我可能有98.5%的把握)。我没有安装工卡插件。

看看下面关于徽章的一些很棒的实验:

代码语言:javascript
复制
def currentBuild = Thread.currentThread().executable
def ws = manager.build.workspace.getRemote()
String desc = new File(ws + "/VERSION.txt").text
currentBuild.setDescription(desc)

if (desc.contains("ERROR")) {
  coverageText="VarkeninK, SomethinK iz bad."
  // Apologies :-7 I can only assume this was from Viktor in http://www.userfriendly.org/ web comic
  manager.addShortText(coverageText, "black", "repeating-linear-gradient(45deg, 
yellow, yellow 10px, Orange 10px, Orange 20px)", "0px", "white")
}

manager.addShortText("GreyWhite0pxWhite", "grey", "white", "0px", "white")
manager.addShortText("BlackGreen0pxWhite", "black", "green", "0px", "white")
manager.addShortText("BlackGreen5pxWhite", "black", "green", "5px", "white")
manager.addShortText("VERSION WhiteGreen0pxWhite", "white", "green", "0px", "white")
manager.addShortText("WhiteGreen5pxWhite", "white", "green", "5px", "white")

manager.addShortText("VERSION Black on Lime Green", "black", "limegreen", "0px", "white")

// darkgrey is lighter than grey!! :-P
manager.addShortText("OBSOLETE YellowDarkGrey5pxGrey", "yellow", "darkgrey", "5px", "grey")
manager.addShortText("OBSOLETE YellowGrey5pxGrey", "yellow", "grey", "5px", "grey")


manager.removeBadges()


manager.addShortText("VERSION Black on Lime Green", "black", "limegreen", "0px", "white")
manager.addShortText(desc, "black", "limegreen", "5px", "white")
manager.addShortText("OBSOLETE YellowGrey5pxGrey", "yellow", "grey", "5px", "grey")

manager.addBadge("warning.gif", "Warning test")
manager.addWarningBadge("other warning test")


// https://wiki.jenkins.io/display/JENKINS/Groovy+Postbuild+Plugin

// contains(file, regexp) - returns true if the given file contains a line matching regexp.
// logContains(regexp) - returns true if the build log file contains a line matching regexp.
// getMatcher(file, regexp) - returns a java.util.regex.Matcher for the first occurrence of regexp in the given file.
// getLogMatcher(regexp) - returns a java.util.regex.Matcher for the first occurrence of regexp in the build log file.
// setBuildNumber(number) - sets the build with the given number as current build. The current build is the target of all methods that add or remove badges and summaries or change the build result.
// addShortText(text) - puts a badge with a short text, using the default format.
// addShortText(text, color, background, border, borderColor) - puts a badge with a short text, using the specified format.
// addBadge(icon, text) - puts a badge with the given icon and text. In addition to the 16x16 icons offered by Jenkins, groovy-postbuild provides the following icons:
//  - completed.gif
//  - db_in.gif
//  - db_out.gif
//  - delete.gif
//  - error.gif
//  - folder.gif
//  - green.gif
//  - info.gif
//  - red.gif
//  - save.gif
//  - success.gif
//  - text.gif
//  - warning.gif
//  - yellow.gif
// addBadge(icon, text, link) - like addBadge(icon, text), but the Badge icon then actually links to the given link (since 1.8)
// addInfoBadge(text) - puts a badge with  info icon and the given text.
// addWarningBadge(text) - puts a badge with  warning icon and the given text.
// addErrorBadge(text) - puts a badge with  error icon and the given text.
// removeBadges() - removes all badges from the current build.
// removeBadge(index) - removes the badge with the given index.
// createSummary(icon) - creates an entry in the build summary page and returns a summary object corresponding to this entry. The icon must be one of the 48x48 icons offered by Jenkins. You can append text to the summary object by calling its appendText methods:
// appendText(text, escapeHtml)
// appendText(text, escapeHtml, bold, italic, color)
// removeSummaries() - removes all summaries from the current build.
// removeSummary(index) - removes the summary with the given index.
// buildUnstable() - sets the build result to UNSTABLE.
// buildFailure() - sets the build result to FAILURE.
// buildSuccess() - sets the build result to SUCCESS.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15482846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档