我使用 jest-sonar-reporter 进行覆盖,如下所示:
包.json
{
"name": "app",
"version": "1.0.0",
"description": "The task runner packages for Gulp",
"main": "gulpfile.js",
"scripts": {
...
"test": "jest --coverage",
...
},
"devDependencies": {
...
"jest": "26.0.1",
"jest-sonar-reporter": "2.0.0",
...
},
"jest": {
...
"collectCoverage": true,
"testResultsProcessor": "jest-sonar-reporter"
},
"jest-junit": {
"suiteName": "jest tests",
...
}
}
Run Code Online (Sandbox Code Playgroud)
我在npm run test后生成了 test-report.xml 文件,如下所示:
测试报告.xml
<?xml version="1.0" encoding="UTF-8"?>
<testExecutions version="1">
<file path="<path to>\AreaList.test.jsx">
<testCase name="Description 1 " duration="6"/>
</file>
<file path="<path to>\selectors.search.test.js">
<testCase name="Description 2 " duration="2"/> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Jenkins 管道emailext附加模板文件。模板文件中的变量 (PROJNAME) 不可访问,我收到了异常电子邮件:
模板渲染期间引发的异常:没有这样的属性:类的环境:SimpleTemplateScript21 groovy.lang.MissingPropertyException:没有这样的属性:类的环境:SimpleTemplateScript21 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) 在 org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) 在 SimplerunTemplate1(AbstractCallSite.java:307)。 1) 在 groovy.text.SimpleTemplateEngine$SimpleTemplate$1.writeTo(SimpleTemplateEngine.java:168) 在 groovy.text.SimpleTemplateEngine$SimpleTemplate$1.toString(SimpleTemplateEngine.java:180) 在 hudson.plugins.emailext.plugins.plugins. .renderTemplate(ScriptContent.java:151) 在 hudson.plugins。emailext.plugins.content.ScriptContent.evaluate(ScriptContent.java:82) at org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.evaluate(DataBoundTokenMacro.java:208) at org.jenkinsci.plugins.tokenmacro.Parser.processToken(Parser. java:308) at org.jenkinsci.plugins.tokenmacro.Action$KiHW1UeqOdqAwZul.run(Unknown Source) at org.parboiled.matchers.ActionMatcher.match(ActionMatcher.java:96) at org.parboiled.parserunners.BasicParseRunner.match( BasicParseRunner.java:77) 在 org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351)parboiled.matchers.ActionMatcher.match(ActionMatcher.java:96) 在 org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) 在 org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351)parboiled.matchers.ActionMatcher.match(ActionMatcher.java:96) 在 org.parboiled.parserunners.BasicParseRunner.match(BasicParseRunner.java:77) 在 org.parboiled.MatcherContext.runMatcher(MatcherContext.java:351)
流水线脚本:
stage('Email') {
def mailRecipients = "myemail@abc.com"
def jobStatus = currentBuild.currentResult
env.PROJNAME = 'project_name'
echo "projname is ${PROJNAME}"
emailext body: '''${SCRIPT, template="test.template"}''',
mimeType: 'text/html',
subject: "[Jenkins] ${jobStatus}",
to: "${mailRecipients}"
} …Run Code Online (Sandbox Code Playgroud) jenkins jenkins-plugins email-ext jenkins-pipeline jenkins-email-ext