My Jenkins Pipeline fails even though no stage has an error:
The console log also shows no problems, but Build status: FAILURE.
Any tips on how to troubleshoot this would be appreciated.
It was a wrong path for a artifactory upload, this let the pipeline silently fail.
Related
There is a Jenkins freestyle job that is triggered by some Gerrit events.In response to triggers, it downloads the changes and runs a Sonarqube Analysis. The Sonarqube comments detailing the results are to be posted on Gerrit after the analysis is complete.This is the expected behaviour.
As of now, In Jenkins, the Sonarqube execution is success. But the build is failed mentioning the error " *ERROR: Build step failed with exception java.lang.IllegalArgumentException: Gerrit change number is empty*
Could anyone please help on this?
Reference:https://plugins.jenkins.io/sonar-gerrit/
Followed the same steps as mentioned in the above document.
Jenkins console output
Expected: The Sonarqube should post the comments to the respective Gerrit change,whether the Sonar-verified is +1/-1.
From time to time our Jenkins pipeline is marked as unstable, after researching it I found that it originates from the Junit plugin, which is publishing test results.
The weird thing is that all the tests are successfully passing (logs and also the whole pipeline proceeding), however the exported test results show that there are some errors.
Can anyone explain this to me?
All tests are passing (logs):
The test results exported by junit are showing some failures:
The whole build is marked as unstable (yellow):
I have a Jenkins Job DSL job that worked well until about january (it is not used that often). Last week, the job failed with the error message ERROR: java.io.IOException: Failed to persist config.xml (no Stack trace, just that message). There were no changes to the job since the last successful execution in january.
[...]
13:06:22 Processing provided DSL script
13:06:22 New run name is '#15 (Branch_B20_2_x)'
13:06:22 ERROR: java.io.IOException: Failed to persist config.xml
13:06:22 [WS-CLEANUP] Deleting project workspace...
13:06:22 [WS-CLEANUP] Deferred wipeout is used...
13:06:22 [WS-CLEANUP] done
13:06:22 Finished: FAILURE
I thougt that between january and noew, maybe some plugin was updated and the DSL script is now wrong, so I changed my DSL script to the most easy one I could imagine (example from job-dsl plugin page):
job('example') {
steps {
shell('echo Hello World!')
}
}
But the job still fails with the exact same error.
I checked the jenkins logs but nothing to see.
I am running jenkins in a docker swarm container and each job is executed in an own build agent conatiner using docker-swarm-plugin (no changes to that either, worked in january).
The docker deamon logs also show no errors.
The filesystem for the workspace of jenkins also is not full and the user in the build agent container has write access to taht file system.
It even does not work, when I mount an empty tmpfs to the workspace.
Does anyone have an idea what goes wrong or at least a hint where to continue searching for that error?
Jenkins version: 2.281
job-dsl plugin version: 1.77
Docker version: 20.10.4
Problem was solved by updating jenkins to 2.289
Seems like there war some problem with the combination of the versions before. I will keep you updated if some of the next updates chnages anything.
I have a pipeline that I want to run e2e test after deploying to uat environment, the e2e test runs on gitlab. What I want to do is to let gitlab use webhook to trigger jenkins to decide if the build could go to production or not. So the pipline looks as below.
After deploying to uat, I can send the webhook to trigger e2e test on gitlab. And gitlab can send the webhook to jenkins, however, as the pipeline job e2e received the webhook and build success. It does not change the pipeline job status, and hence, we can not proceed to deploy to production unless we manually click the trigger on e2e job. And I already try to use currentBuild.currentResult and currentBuild.result which doesn't seem to work.
What should I do to solve this?
Update
I am not using the new pipeline way with groovy, instead, I'm doing it the old way like this. But I supposed this is not related to the issue I'm trying to solve here.
Let me provide more details about the problem. After e2e test is done, I send below request from gitlab to jenkins
curl "SERVER_URL/job/MY_XXX_PROJECT/view/Pipeline/job/X.X%20E2E%20my_e2e_test_result/buildWithParameters?token=xxxxxxxxxxxxxx&PARENT_BUILD_NUMBER=123¤tBuild.currentResult=SUCCESS¤tBuild.Result=SUCCESS"
And here is the pipeline, and if I check the job in SERVER_URL/job/MY_XXX_PROJECT/view/Pipeline/job/X.X%20E2E%20my_e2e_test_result/. The job is actually built SUCCESS.
However, the status shows like nothing happened, and we cannot proceed to deploy production without manually clicking the trigger button on the same job(e2e) again.
If you're just looking for a way for the job to update its own state, use the unstable and the error steps.
pipeline {
agent any
stages {
stage('Hello') {
steps {
echo 'This job is now a success. All jobs are a success until marked otherwise'.
//success 'This will fail. There's no such thing as a success step'
unstable 'This stage is now unstable'
error 'This job is now failed'
unstable 'This job is still failed. Build results can only get worse. They can never be improved.'
}
}
}
}
Notice that there's no such thing as a success step. Probably because all jobs are a success until told otherwise. And the overall result of a job cannot be improved. See the documentation for catchError here.
Note that the build result can only get worse, so you cannot change the result to SUCCESS if the current result is UNSTABLE or worse.
I have configured Jenkins Job for Sonar Quality Gate and Code Coverage. Below is the Jenkins job set Up. When I trigger the build I see below error. Most of my Jenkins jobs are failing because of this issue. Please help me out from this.
Jenkins Job setup
Error Logs
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: Error at line 2 of coverage report C:\Location.xml
at org.sonar.plugins.coverage.generic.GenericCoverageSensor.loadReport(GenericCoverageSensor.java:130)
at org.sonar.plugins.coverage.generic.GenericCoverageSensor.analyseWithLogger(GenericCoverageSensor.java:95)
at org.sonar.plugins.coverage.generic.GenericCoverageSensor.analyse(GenericCoverageSensor.java:91)
at org.sonar.plugins.coverage.generic.ReportParser.parse(ReportParser.java:82)
at org.sonar.plugins.coverage.generic.GenericCoverageSensor.loadReport(GenericCoverageSensor.java:126)
... 31 more
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
The SonarQube Scanner did not complete successfully
21:44:09.12 Creating a summary markdown file...
21:44:09.122 Post-processing failed. Exit code: 1
The answer is there in the log:
org.sonar.plugins.dotnet.tests.ParseErrorException: Missing root element 'test-results' in C:\UC\ProductEligibility\BTS\results.xml at line 2
So the results.xml is not valid xml and causes a parse error and kills the analysis. So whatever creates that file, is causing the issue in the end.
Try to remove that parameter to verify if the analysis runs correctly now.