Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cnes report is executed too soon in the Sonar Scanner stage #732

Closed
braisvq1996 opened this issue Oct 5, 2021 · 5 comments
Closed

Cnes report is executed too soon in the Sonar Scanner stage #732

braisvq1996 opened this issue Oct 5, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@braisvq1996
Copy link
Contributor

braisvq1996 commented Oct 5, 2021

Describe the bug
After the Sonarqube scan ends successfully, cnes report is executed but if the backgound task in SonarQube have not ended the information picked would be from the previous scanner or if the branch is new, then the pipeline will fail.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new branch in Bitbucket
  2. Execute a pipeline with Sonar scan enabled
  3. Check the time of the execution
  4. See error

Expected behavior
The cnes report should be executed after the Sonarqube Background task has finished

Screenshots

Issue we found
Captura2

Execution timeline
Captura3

Affected version (please complete the following information):

  • OpenShift: 3.11
  • OpenDevStack 3.1

Log Output (ensure to remove any confidential information like tokens, project names, etc.

12:49:02.629 DEBUG: Post-jobs : 
12:49:02.930 INFO: Analysis total time: 1:46.421 s
12:49:02.932 INFO: ------------------------------------------------------------------------
12:49:02.932 INFO: EXECUTION SUCCESS
12:49:02.932 INFO: ------------------------------------------------------------------------
12:49:02.932 INFO: Total time: 1:51.673s
12:49:03.019 INFO: Final Memory: 14M/50M
12:49:03.019 INFO: ------------------------------------------------------------------------
[Pipeline] }
[Pipeline] // withSonarQubeEnv
[Pipeline] echo
DEBUG: [key-client-sq-scan]  (took 115043 ms)
[Pipeline] withSonarQubeEnv
Injecting SonarQube environment variables using the configuration: SonarServerConfig
[Pipeline] {
[Pipeline] sh (Generate CNES Report)
+ java -jar /usr/local/cnes/cnesreport.jar -s https://sonarqube-ods.XXXX.com -t ****** -p key-client -a jenkins-key-cd-key-cd-cdbmgr-mro-pipeline-master-59 -b release/0.0.2
SonarQube URL: https://sonarqube-ods.XXXX.com
SonarQube online: true
Detected SonarQube version: 8.2.0
[ERROR] Not found error sent by SonarQube server (code 404, URL https://sonarqube-ods.XXXX.com/api/navigation/component?component=key-client&branch=release/0.0.2, Error {"errors":[{"msg":"Component 'key-client' on branch 'release/0.0.2' not found"}]}), please check cnesreport compatibility with your SonarQube server version.
[Pipeline] }
[Pipeline] // withSonarQubeEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] echo
[SonarQube Analysis-client] **** ENDED stage 'SonarQube Analysis' for component 'client' branch 'release/0.0.2' **** (took 118356 ms)

Additional context
It took 3 seconds after the Sonar scan cli has finished and the error appeared in the pipeline (cnes report), and checking the background task for this issue, it took 10 seconds to finish.
So if the cnes report was executed 15 seconds later, it would not have failed.
Checking the history of the time it takes the background tasks to finish, I can see different duration for the tasks, from miliseconds up to 20 seconds.

image

@michaelsauter @metmajer

@braisvq1996 braisvq1996 added the bug Something isn't working label Oct 5, 2021
@braisvq1996
Copy link
Contributor Author

braisvq1996 commented Oct 5, 2021

Should we set a sleep between the sonar scanner cli and cnes report here?

@michaelsauter
Copy link
Member

Nice one :(

Maybe we can use the API to check if the task finished?

@braisvq1996
Copy link
Contributor Author

braisvq1996 commented Oct 5, 2021

Yeah, already working on that, I am planing to use this API endpoint: api/ce/task and check the status

image

@braisvq1996
Copy link
Contributor Author

Pull requests for master, 4.x and 3.x branches have been merged with the fix for this issue

@metmajer
Copy link
Member

Well done @braisvq1996 :)

michaelsauter added a commit to opendevstack/ods-pipeline that referenced this issue Oct 12, 2021
* Do not generate reports when pull request exists for scanned branch.
For more information, see
opendevstack/ods-jenkins-shared-library#663
and cnescatlab/sonar-cnes-report#159.

* Ensure background task on server finishes before generating a
report. For more information, see
opendevstack/ods-jenkins-shared-library#732.

* Unify logging approach: instead of printing to STDOUT directly for
some messages, funnel everything through the logger instance. Other
tasks should adopt this as well.

Closes #227.
michaelsauter added a commit to opendevstack/ods-pipeline that referenced this issue Oct 12, 2021
* Do not generate reports when pull request exists for scanned branch.
For more information, see
opendevstack/ods-jenkins-shared-library#663
and cnescatlab/sonar-cnes-report#159.

* Ensure background task on server finishes before generating a
report. For more information, see
opendevstack/ods-jenkins-shared-library#732.

* Unify logging approach: instead of printing to STDOUT directly for
some messages, funnel everything through the logger instance. Other
tasks should adopt this as well.

Closes #227.
michaelsauter added a commit to opendevstack/ods-pipeline that referenced this issue Oct 14, 2021
* Do not generate reports when pull request exists for scanned branch.
For more information, see
opendevstack/ods-jenkins-shared-library#663
and cnescatlab/sonar-cnes-report#159.

* Ensure background task on server finishes before generating a
report. For more information, see
opendevstack/ods-jenkins-shared-library#732.

* Unify logging approach: instead of printing to STDOUT directly for
some messages, funnel everything through the logger instance. Other
tasks should adopt this as well.

Closes #227.
michaelsauter added a commit to opendevstack/ods-pipeline that referenced this issue Oct 14, 2021
* Do not generate reports when pull request exists for scanned branch.
For more information, see
opendevstack/ods-jenkins-shared-library#663
and cnescatlab/sonar-cnes-report#159.

* Ensure background task on server finishes before generating a
report. For more information, see
opendevstack/ods-jenkins-shared-library#732.

* Unify logging approach: instead of printing to STDOUT directly for
some messages, funnel everything through the logger instance. Other
tasks should adopt this as well.

Closes #227.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants