Giter VIP home page Giter VIP logo

sonar-buildbreaker-vsts's People

Contributors

simondel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sonar-buildbreaker-vsts's Issues

Error when using the build breaker task 2 times in AzureDevOps pipeline

Hello Team,
We are using the SonarQube build breaker task 2 times in the same Azure DevOps build pipeline, since we have 2 separate scans configured. So we will scan the webui source code(java) which gets posted to one Sonar project, then later in the pipeline we scan the DB source code, which gets posted to another Sonar project. We would like to fail the build if either quality gate fails. However, with this configuration we get the following error when the second build breaker task executes:
##[error]The operation was canceled.
Is this type of configuration supported?
image

Thanks in advance for the insight!
-Tom

Azure Devops Server 2019

Version of Build Breaker: 8.0.0
Version of SonarQube: 4.7.2

Tasks always succeeding but getting the following:

Getting task report from file undefined
(node:7688) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: path must be a string or Buffer

or

Number of analyses in this build: 0
Summary of statusses:
##[section]Finishing: Break build on quality gate failure

Build breaker cannot find reports

Hi Simon.

I'm using sonar 6.7 and build breaker 8 and I'm getting the following output from build breaker:

##[section]Starting: Break build on quality gate failure
==============================================================================
Task         : SonarQube build breaker
Description  : Break the build when the quality gate fails.
Version      : 8.0.0
Author       : Simon de Lang
Help         : 
==============================================================================
Number of analyses in this build: 0
Summary of statusses: 
##[section]Finishing: Break build on quality gate failure

I can see from a previous step that the report-tasks.txt is being written to the following path:
13:40:25.010 DEBUG: Report metadata written to D:\VSTS\Agents\A\_work\179\.sonarqube\out\.sonar\report-task.txt

Any ideas? Cheers!

Doesn't work with SonarCloud

Allways fails the build with the following message: Unhandled: Cannot read property 'analysisId' of undefined

Adding additional details in the SonarCloud build breaker logs

First of all thank you for this SonarCloud build breaker extension. We are using it in our Azure DevOps pipelines and has been really helpful.
image

Currently this is the output that we get when the quality gate is failing
image

I was wondering if it could be possible to add there in the logs the reason(s) why the quality gate has failed.
It would be a great improvement for us.

Best regards!

Getting task report from file undefined

The build breaker task started to fail (i.e. not breaking the build when it should, the task is always green) for all our pipelines between August 14 and August 23 according to our history, with this error:

Getting task report from file undefined
(node:20441) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: path must be a string or Buffer

This matches with

  • the SonarQube extension being upgraded to 4.8.0
  • the SonarQube breaker extension being upgraded to 7.0.8 or 8.0.0.

We're using SonarQube 6.7.3.
The analysis summary appears properly in the build summary.
The Publish Quality gate task does not report any issue and the analysis can be seen in Sonar.

Full debug output of the buid breaker task:

==============================================================================
Task         : SonarQube build breaker
Description  : Break the build when the quality gate fails.
Version      : 7.0.5
Author       : Simon de Lang
Help         : 
==============================================================================
##[debug]agent.TempDirectory=/var/vsts/work/_temp
##[debug]loading inputs and endpoints
##[debug]loading INPUT_SONARQUBE
##[debug]loading ENDPOINT_AUTH_11da1f38-54c8-4f4d-bfdb-d9b17701cc40
##[debug]loading ENDPOINT_AUTH_SCHEME_11da1f38-54c8-4f4d-bfdb-d9b17701cc40
##[debug]loading ENDPOINT_AUTH_PARAMETER_11da1f38-54c8-4f4d-bfdb-d9b17701cc40_USERNAME
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loading SECRET_SONARQUBE_ENDPOINT
##[debug]loaded 9
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]SonarQube=11da1f38-54c8-4f4d-bfdb-d9b17701cc40
##[debug]11da1f38-54c8-4f4d-bfdb-d9b17701cc40=https://*********/
##[debug]11da1f38-54c8-4f4d-bfdb-d9b17701cc40 auth param apitoken = null
##[debug]11da1f38-54c8-4f4d-bfdb-d9b17701cc40 auth param username = ***
##[debug]11da1f38-54c8-4f4d-bfdb-d9b17701cc40 auth param password = null
##[debug]organization=null
##[debug]Build.BuildNumber=20190923.4
##[debug]Agent.TempDirectory=/var/vsts/work/_temp
##[debug]defaultRoot: '/var/vsts/work/_temp'
##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
##[debug]findOptions.followSymbolicLinks: 'true'
##[debug]matchOptions.debug: 'false'
##[debug]matchOptions.nobrace: 'true'
##[debug]matchOptions.noglobstar: 'false'
##[debug]matchOptions.dot: 'true'
##[debug]matchOptions.noext: 'false'
##[debug]matchOptions.nocase: 'false'
##[debug]matchOptions.nonull: 'false'
##[debug]matchOptions.matchBase: 'false'
##[debug]matchOptions.nocomment: 'false'
##[debug]matchOptions.nonegate: 'false'
##[debug]matchOptions.flipNegate: 'false'
##[debug]pattern: 'sonar/20190923.4/**/report-task.txt'
##[debug]findPath: '/var/vsts/work/_temp/sonar/20190923.4'
##[debug]statOnly: 'false'
##[debug]findPath: '/var/vsts/work/_temp/sonar/20190923.4'
##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
##[debug]findOptions.followSymbolicLinks: 'true'
##[debug]0 results
##[debug]found 0 paths
##[debug]applying include pattern
##[debug]adjustedPattern: '/var/vsts/work/_temp/sonar/20190923.4/**/report-task.txt'
##[debug]0 matches
##[debug]0 final results
Getting task report from file undefined
(node:20441) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: path must be a string or Buffer
##[section]Finishing: Break build on SonarQube quality gate failure

Whereas the Publish task ends with this:

##[debug]adjustedPattern: '/var/vsts/work/7/**/report-task.txt'
##[debug]1 matches
##[debug]1 final results
##[debug][SQ] Searching for **/report-task.txt - found 1 file(s)
##[debug][SQ] Read Task report file: /var/vsts/work/7/s/target/sonar/report-task.txt
##[debug][SQ] Parse Task report file: projectKey=**********************

Thanks for your help

Plugin randomly stopped working...

We were using version 6, which suddenly stopped working without any obvious reason.
I enabled debug output, here's part of that:

##[debug]76382 results
##[debug]found 76382 paths
##[debug]applying include pattern
##[debug]adjustedPattern: 'C:\DeltaPi\agent_work\10*\report-task.txt'
##[debug]1 matches
##[debug]1 final results
##[debug]SONARQUBE_ENDPOINT=
**
##[debug]task result: Failed
##[error]Unhandled: Cannot read property 'status' of undefined
##[debug]Processed: ##vso[task.issue type=error;]Unhandled: Cannot read property 'status' of undefined
##[debug]Processed: ##vso[task.complete result=Failed;]Unhandled: Cannot read property 'status' of undefined

The file does appear to exist (C:\DeltaPi\agent_work\10.sonarqube\out.sonar\report-task.txt) and has the following contents:

projectKey=DeltaPi
serverUrl=http://d1nlbodwrvsts:9000
serverVersion=6.7.5.38563
dashboardUrl=http://d1nlbodwrvsts:9000/dashboard/index/DeltaPi
ceTaskId=AWyUSQKpYJwQvCdTe4Ny
ceTaskUrl=http://d1nlbodwrvsts:9000/api/ce/task?id=AWyUSQKpYJwQvCdTe4Ny

Note that this file only contains LineFeed line endings (not sure if that matters)

We are using SonarQube LTS so nothing should've changed there...

I tried using the latest version of the plugin, version 7, the following is part of the debug output:

##[debug]pattern: 'sonar\20190815.3*\report-task.txt'
##[debug]findPath: 'C:\DeltaPi\agent_work_temp\sonar\20190815.3'
##[debug]statOnly: 'false'
##[debug]findPath: 'C:\DeltaPi\agent_work_temp\sonar\20190815.3'
##[debug]findOptions.followSpecifiedSymbolicLink: 'true'
##[debug]findOptions.followSymbolicLinks: 'true'
##[debug]0 results
##[debug]found 0 paths
##[debug]applying include pattern
##[debug]adjustedPattern: 'C:\DeltaPi\agent_work_temp\sonar\20190815.3*
\report-task.txt'
##[debug]0 matches
##[debug]0 final results
Getting task report from file undefined
(node:5036) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: path must be a string or Buffer

It can't find the file, which makes sense as it's not located in the temp folder.

What can be done to fix it?

I have not originally configured the pipeline, the one who did has left the company, so please excuse me for any of my ignorance.

SonarQube analysis failing

@remkoseelig mentioned in #1 that the has the following issue:

Using VSTS and SonarQube 6.7.1 I the build/plugin fails with: "Cannot read property 'task' of undefined".

@nboeckmann has this same issue but with TFS:

Hey,

I'm having the same issue as @remkoseelig and I'm using the 7.x version. I'm still getting the same error message as he does: "Cannot read property 'task' of undefined".

I'm using SQ Server 6.7.1 and I can see in the access.log that the queries are made OK and that content is returned. I've also validated the output of the queries and they seem to be ok considering what you have written earlier in this post.

Do you have any idea what can be the reason for it?

letsencrypt cert issues

image
Getting a vague issue, but we're using the newest release that supposedly fixes these... is there some cache that needs cleared on the build agents or is this still actively being worked out?

Build breaker for .Net Core sonar cloud analysis with Azure DevOps

Hello,

We are using sonarcloud to analyze .net core projects with Azure DevOps.

Tasks in the pipeline:

task: CmdLine@2
displayName: Dotnet sonarscanner start
inputs:
script: |
echo Dotnet sonarscanner start
dotnet “SonarScanner.MSBuild.dll” begin /k:"" /o:"" /d:sonar.host.url=“https://sonarcloud.io” /d:sonar.login=""

Task to execute .net core build

task: CmdLine@2
displayName: Dotnet sonarscanner end
inputs:
script: |
echo Dotnet sonarscanner end
dotnet “$(Build.SourcesDirectory)\Tools\Sonarqube\SonarScanner.MSBuild.dll” end

- task: sonarcloud-buildbreaker@2
  inputs:
    SonarCloud: 'sonarcloud'
    organization: 'genomics'

We are getting the below logs from the build breaker task:

Starting: sonarcloudbuildbreaker

==============================================================================


Task         : SonarCloud build breaker

Description  : Break the build when the quality gate fails.

Version      : 2.1.0

Author       : Simon de Lang

Help         : 

==============================================================================

Number of analyses in this build: 0

Summary of statusses: 

Finishing: sonarcloudbuildbreaker` 

Not sure why the output contains "Number of analyses in this build: 0".

Also the build should be failed, but it succeeds. Not sure what's wrong in the pipeline setup.

Any inputs will be helpful. Thanks in advance.

Sonar Cloud build breaking after 2.1.1 upgrade

After the recent 2.1.1 upgrade, all our pipelines started breaking, with the error:

Starting: Break build on quality gate failure

Task : SonarCloud build breaker
Description : Break the build when the quality gate fails.
Version : 2.1.1
Author : Simon de Lang
Help :

##[error]Unhandled: Unexpected token ...
Finishing: Break build on quality gate failure


Is there a work around?

SonarQube Publish Quality Gate and Build Breaker Failing

Hi Simondel,

            Appreciate your support in the below issue regarding SonarQube in our Azure pipeline.

            I have used some Azure built-in tasks to integrate our SonarQube instance and enable the code analysis inside our pipeline. I have used “SonarQubePrepare@4” and “SonarQubeAnalyze@4” tasks , those went fine and passed but when I try to use the tasks as  “SonarQubePublish@4” to enable publishing of the SonarQuality gate and then use “sonar-buildbreaker@8” to stop the pipeline in case of failure,  publishing stage is usually not passing with the below error.

#[error][SQ] API GET '/api/ce/task' failed, status code was: 404

##[error][SQ] Could not fetch task for ID 'AXcXIGd0GolG0E5ghxBy'
##[error][SQ] API GET '/api/ce/task' failed, status code was: 404
##[error][SQ] API GET '/api/ce/task' failed, status code was: 404
##[error][SQ] API GET '/api/ce/task' failed, status code was: 404
##[error][SQ] API GET '/api/ce/task' failed, status code was: 400

I have searched a lot and all clues are pointing that “report-task.txt” file may be cached from old builds and the solution is that I remove it but actually I am not sure where it is generated inside the working directory of the pipeline. Worth to be mentioned that although this solution is proposed, many people are still complaining from the same issue even after following it and the case is not resolved yet on many platforms.

            Thanks to support how can I resolve this issue. Any proposal will be much appreciated as it’s a great blocker to us since stopping the pipeline based on the SonarQube quality gate result is very important stage in our pipelines.

[Ehancement]Get the analysis result in variable

I would like to execute a task after the build breaker if the quality gate failed. Something like this would help:

- task: sonar-buildbreaker@8
  name: buildbreaker
  displayName: Check Quality Gate
  continueOnError: true
  inputs:
    SonarQube: SonarQube
    OutputVariableName: myVariableName
- task: xxxxx
  condition: $(buildbreaker.myVariableName)
  ...

I can submit a PR if you want.

Execution failure with socket hang up error

Hi,

Our execution is suddenly failing with socket hang up error (after a few hours running) as per screen shot below as if it couldn't access/authenticate Sonarqube, though previous task (Publish Quality Gate Result) does using very same Sonarqube endpoint.

image

Any hints?
Thanks.

why the sq enpoint need to pass explicitly

the endpoint is available as serverUrl in report-task.txt file.
So why we need to pass the endpoint explicitly in the task?
Checking since we dont need to pass the endpoint in task "Publish Quality Gate Result"!

Requirements

I got a question, I have extension “Break build on quality gate failure” version 6.2.3, and it seems that it required has "Publish Quality Gate Result", if i disable that task i get the following error:

image

But i got a problem with task Publish Quality Gate result, it taking so long to finish, despite that the task "Run Code Analysis" is finished. Why this happen? it is necessary to have the task "Publish Quality Gate Result" configured in my pipeline before “Break build on quality gate failure” task?

I have SonarQube 4.3.0.

Thanks for your help.

Report task file not found

Since the update of the sonar plugin to version 4.7.0 we get the following error:

(node:4115) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: path must be a string or Buffer
Getting task report from file undefined

We checked the changes of the sonar plugin and recognised that the result will now placed in the tmp directory rather than the build folder.

see:
common/ts/sonarqube/TaskReport.ts

in the following commit:
SonarSource/sonar-scanner-vsts@956ba21#diff-3a4ea7e6eb2e6b2767e851d8f1b58b72

SonarQube Build Break task was not working

As we are using sonar build break task in Azure CI past one hour we are getting below error message, kindly help us on this.

I've run below task in debug, kindly check.

Starting: Break build on quality gate failure

Task : SonarQube build breaker
Description : Break the build when the quality gate fails.
Version : 8.1.1
Author : Simon de Lang
Help :

##[debug]Using node path: /opt/Azure-BuildAgent/externals/node/bin/node
##[debug]agent.TempDirectory=/opt/Azure-BuildAgent/_work/_temp
##[debug]loading inputs and endpoints
##[debug]loading INPUT_SONARQUBE
##[debug]loading ENDPOINT_AUTH_c2056c3c-68dd-4298-9c16-1eb568e42d14
##[debug]loading ENDPOINT_AUTH_SCHEME_c2056c3c-68dd-4298-9c16-1eb568e42d14
##[debug]loading ENDPOINT_AUTH_PARAMETER_c2056c3c-68dd-4298-9c16-1eb568e42d14_USERNAME
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SONARQUBE_ENDPOINT
##[debug]loaded 8
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]task result: Failed
##[error]Unhandled: Unexpected token ...
##[debug]Processed: ##vso[task.issue type=error;]Unhandled: Unexpected token ...
##[debug]Processed: ##vso[task.complete result=Failed;]Unhandled: Unexpected token ...
Finishing: Break build on quality gate failure

Failing condition summary

Hello, first of all thank you for the vsts extention.

It would be nice if you could not only get the status. There was a good plugin on the SonarQube Server side called QualityGate breaker. This just does not work any more for VSTS.

But it also printed a summery of the Conditions which are failed.
For Example:
New Major Issues: 3 > 0
Code Coverage on new code: 50 < 75

Build break task failing

Hello,
The build breaker task is all of a sudden failing with the following error. Not sure if a change to the Azure DevOps API caused the following but wanted to reach out to see if you had any insight.

Error:
##[section]Starting: Break build on quality gate failure

Task : SonarQube build breaker
Description : Break the build when the quality gate fails.
Version : 7.0.4
Author : Simon de Lang
Help :

Getting task report from file D:\AzDOAgents\Agent1_work\53.sonarqube\out.sonar\report-task.txt
Retrieving analysisId from https://<OUR_URL>/sonar/api/ce/task?id=AWyMCyPRF-FKoHTXr7-L
##[error]Unknown result from previous http request. The body is: [object Object]. Statuscode is 200
Retrieving quality gate report from https://<OUR_URL>/sonar/api/qualitygates/project_status?analysisId=undefined
##[error]Something went wrong! Got statuscode 404 and error null
##[error]Unknown result from previous http request. The body is: [object Object]. Statuscode is 404
##[error]Unhandled: Cannot read property 'status' of undefined
##[section]Finishing: Break build on quality gate failure

Build Breaker don't see SonarCloud scans

We have CI/CD, built on AzureDevops. Quality Gate Job with SonarCloud scan.
Everything was OK and it was working. Here is example of output:

==============================================================================
Task         : SonarCloud build breaker
Description  : Break the build when the quality gate fails.
Version      : 2.1.2
Author       : Simon de Lang
Help         : 
==============================================================================
Number of analyses in this build: 1
Summary of statusses: "ERROR"
##[error]The analysis did not pass the quality gate because because at least one analysis has has the status 'ERROR'. Attempting to fail the build!
Finishing: Break build on quality gate failure

Then 12.06.2023 I turned off build breaker (needed for testing)

And the problem is that when I turned it on back yesterday (14.06.2023), SonarCloud Build Breaker stopped to break builds when Sonar scan find something. So I checked the output of the build breaker step and found that it cannot see the scan result. Output of task is following:

==============================================================================
Task         : SonarCloud build breaker
Description  : Break the build when the quality gate fails.
Version      : 2.1.2
Author       : Simon de Lang
Help         : 
==============================================================================
Number of analyses in this build: 0
Summary of statusses: 
Finishing: Break build on quality gate failure

What that could be?
The only difference I see is that version of SonarCloud task is different. In scans few days ago, SonarCloud Publish task version was 1.11.3. Now - it is 1.13.0

Here is also part of YAML used in our pipeline:

- task: SonarCloudAnalyze@1
  displayName: 'SonarCloud: Code Analysis'

- task: SonarCloudPublish@1
  displayName: 'SonarCloud: Publish Result'

- task: SimondeLang.sonarcloud-buildbreaker.sonar-buildbreaker.sonarcloud-buildbreaker@2
  displayName: 'SonarCloud: Break build on quality gate failure'
  condition: eq(variables['Build.Reason'], 'PullRequest')
  inputs:
    SonarCloud: 'SonarCloud'
    organization: 'XXXXXXXXXXXXX'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.