I've got Jenkins job with 2 stages generating two separate reports (they use https://plugins.jenkins.io/cucumber-reports/ this plugin and HTML publisher), Jenkins itself is on GKE (so after the job is done and files are generated on the agent they are transferred to master); The issue I've got it that first HTML Report and Cucumber reports are generated properly but when the second stage is run, it overrides some of the files from the first step, resulting in 403 error from Jenkins when checking the report. Any thoughts on how to deal with it?
Access to Jenkins was denied you don't have the authorisation to view this page.
HTTP ERROR 403
Please use ,
reportTitle: 'name'
entry in cucumber step , it wont override your report .
Example:
step([$class: 'CucumberReportPublisher',
failedFeaturesNumber: xxx,
failedScenariosNumber: xxx,
failedStepsNumber: xxxx,
fileExcludePattern: '',
fileIncludePattern: '**/*.json',
jsonReportDirectory: xxx,
parallelTesting: false,
reportTitle: xxx ,
pendingStepsNumber: xx,
skippedStepsNumber: xx,
trendsLimit: 0,
undefinedStepsNumber: xx
])
Jenkins version : Jenkins 2.230
Cucumber reports plugin : 5.2.0
Related
Upgrade the Jenkins to 2.278, after upgrade, if build
error, the content of email show:
$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
Check console output at $BUILD_URL to view the results.
It will not display the real value, but I can find them
in the 'Environment variables ', like:
BUILD_CAUSE MANUALTRIGGER
BUILD_CAUSE_MANUALTRIGGER true
BUILD_DISPLAY_NAME #35
BUILD_ID 35
BUILD_NUMBER 35
BUILD_TAG jenkins-trigger-test-35
BUILD_URL http://192.168.10.99:8080/job/trigger-test/35/
...
then I upgrade the Email Extension Plugin to 2.80, but
still with no lucky.
Does anyone know what's wrong?
Thanks a lot.
The solution is to update Token Macro to 2.14 or later
I'm trying to use the allure report plugin with Jenkins on CentOS7 for a Java maven project that is using TestNg and Allure test adaptor. The tests run fine and allure-results are generated as expected. My build step in the Jenkins file is
post {
always {
script {
allure([
commandline: 'allure',
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: target/allure-results]]
])
}
}
}
I can see the little allure icon in front of the build and when I click on it I get routed to http://xxx.xx.x.xx/index.html#404 with the following information:
URI: /index.html
STATUS: 404
MESSAGE: Not Found
SERVLET: Stapler
In the Jenkins build logs I see the following:
$ /bin/allure generate "/home/path/to/job/target/allure-results" -c -o "/home/path/to/job/allure-report"
WARN: No current version specified. Use `allure switch <version>` to select version of the report.
Allure report was successfully generated.
Creating artifact for the build.
Artifact was added to the build.
Finished: SUCCESS
When I manually try generating the allure report using allure serve, I can view the HTML report in the browser. But it's returning 404 in the Jenkins job.
How do I access $BUILD_LOG in a Jenkins pipeline, or is there a better way of getting the log output?
Going off of this answer, I've been trying to access the $BUILD_LOG environment variable, but when I try
echo "${BUILD_LOG, maxLines=50, escapeHtml=false}"
the build errors out:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 11: unexpected token: BUILD_LOG # line 11, column 29.
echo "${BUILD_LOG, maxLines=50, escapeHtml=false}"
And if I try
echo "$BUILD_LOG"
I get this error:
groovy.lang.MissingPropertyException: No such property: BUILD_LOG for class: groovy.lang.Binding
What am I doing wrong? Or is this the wrong way to access the printed output?
I had the same problem with declarative pipelines and a step like:
emailext(
subject: "foo",
to: "bar",
body: """<p>FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Console output (last 250 lines):<hr><pre>${BUILD_LOG}</pre></p>"""
I had email ext plugin installed.
The solution was to escape the $-sign of the the macro that should be expanded by the plugin, like so:
...
<p>Console output (last 250 lines):<hr><pre>\${BUILD_LOG}</pre></p>"""
...
And be sure to use double quotes.
This way groovy (?) will first expand all the environment variables, and leaves the escaped variables to be dealt with by email ext plugin.
Still haven't found a solution to use BUILD_LOG parameter in a pipeline job with emailext plugin.
As a small solace, I found a workaround to access build log in another way:
currentBuild.rawBuild.getLog(15)
Where 15 is a number of last log lines I want to show.
The example is:
emailext attachLog: true,
body: "Build failed" +
"<br> See attached log or URL:<br>${env.BUILD_URL}" +
"<br><br> <b>The end of build log is:</b> <br>" +
currentBuild.rawBuild.getLog(15).join("<br>"),
mimeType: 'text/html',
subject: "Build failed",
to: 'myemail#somedomain.com'
Note that you have to approve a few script signatures at the In-Process Script Approval in order to allow usage of this function.
From the answer you linked the BUILD_LOG variable is set by the email-extension plugin. Do you have this configured correctly as this may be your issue.
I started to migrate some jobs in jenkins to pipeline execution.
Is there any chance to see the warnings graph in multi branch pipeline jobs? Within my older projects I can configure the graphs with "Configure the trend graph" option. These option will crash in the pipeline syntax tool.
Is there any option to make the graph visible?
I have in my Jenkinsfile:
stage ('Warnings gcc') {
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'GNU Make + GNU C Compiler (gcc)', pattern: 'error_and_warnings.txt']], unHealthy: ''])
}
stage ('Warnings clang') {
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'Clang (LLVM based)', pattern: 'error_and_warnings_clang.txt']], unHealthy: ''])
}
The reports will be generated but no graph is displayed.
UPDATE: Now it still did not work but it is also impossible to use the snipped generator for the warnings plugin.
Entering a file name in the snipped generator for the warning plugin results in a java null pointer exception:
javax.servlet.ServletException: java.lang.NullPointerException
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:796)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:236)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:362)
some more lines follows ...
Mentioned in the revision log for the warnings plugin V 4.56:
Fixed deactivation of trend graphs (using the analysis collector plug-in)
But I use 4.57 and it still did not display any graph!
I posted the problem also to jenkins user list (no feedback for weeks) and also added bug report and bug report
Can anyone reproduce the problem or is the multi-branch pipeline simply still broken at all? Seems to be that there are not so much users for this plugin...
These issues have been resolved with the latest versions of both Jenkins, the pipelines plugin[s], and the plugins you have mentioned above.
Additionally, the bugs you specifically reported have been resolved:
[FIXED JENKINS-39553] Make GitHub plugin BuildableItem aware (#153)
[FIXED JENKINS-39532] Do not access the workspace for pipelines
Update your Jenkins instance and all of your plugins (some of them have interdependencies on others) and after the suggested restart you should be able to display the graph successfully.
I am using a Multibranch Pipeline job to trigger my build. One of the steps of the build is to run Sonar. After the Sonar is run, findbugs-result.xml file is created the target/sonar directory.
I publish the results using the below commands in Groovy. The build shows that there is 1 warning for FindBugs. But I do not see in the Jenkins Dashboard (FindBugs Warning portlet).
If I create a normal Freestyle job and try to do the same thing using a Post-build action, the results are visible on the Jenkins Dashboard.
bat "${env.M2_HOME}/bin/mvn sonar:sonar --settings ../HudsonSettings/settings.xml -B -U -P reporting-plugins"
step([$class: 'FindBugsPublisher', canComputeNew: false, canRunOnFailed: true, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', isRankActivated: true, pattern: '**/target/sonar/findbugs-result.xml', unHealthy: ''])
Can anyone help ?
Thanks and Regards
Saroj Gharat
By default, the Jenkins-Findbugs will look for files with the name findbugsXml.xml.
If your integration is dropping a report with a report filename, you need to add the filename findbugs-result.xml (Under Post-build action > Publish FindBugs analysis result > Findbugs results).