Hi, you must using {} as wrapper. 

stage ('SonarQube Scan'){
            steps {
                withSonarQubeEnv('SonarQube') {
                    withMaven (
                        maven: 'maven 3.3.9',
                        mavenSettingsConfig: 
'cc86690e-095d-4714-92b2-b61861241c7a'){
                        sh 'mvn 
org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar '
                    }
                } // SonarQube taskId is automatically attached to the 
pipeline context
            }
        }
        stage ('Quality Gate') {
            steps {
                timeout(time: 1, unit: 'HOURS') { // Just in case something 
goes wrong, pipeline will be killed after a timeout
                    script {
                        def qg = waitForQualityGate() // Reuse taskId 
previously collected by withSonarQubeEnv
                        if (qg.status != 'OK') {
                            error "Pipeline aborted due to quality gate 
failure: ${qg.status}"
                        }
                    }
                }
            }
        }




Dne pátek 8. září 2017 23:45:13 UTC+2 nup napsal(a):
>
> Hi,
>
> I have been trying to get SonarQube Quality gate to work with latest 
> blueocean on Jenkins, but it does not seem to work.  I am a beginner with 
> blueocean pipeline so any help in fixing this issue would be greatly 
> appreciated.   Please, note the build works and sonarqube report is 
> generated, but only failing at SonarQube Quality Gate status.  I thought 
> this would work out of the box as blueocean now as an added Step to add 
> SonarQube QG status.
>
> I have tried all of the various different steps, but I still get following 
> same error "Unable to get SonarQube task id and/or server name. Please 
> use the 'withSonarQubeEnv' wrapper to run your analysis."
>
> ---------
>
> pipeline {
>
>   agent any
>
>   stages {
>
>     stage('Build') {
>
>       steps {
>
>         sh 'mvn install clean install -Dsonar.login=test 
> -Dsonar.password=test -Dsonar.host.url=http://myserver sonar:sonar '
>
>       }
>
>     }
>
>     stage('Quality Gate') {
>
>       steps {
>
>         sh 'echo "Sonar Analysis"'
>
>         waitForQualityGate()
>
>       }
>
>     }
>
>
> ---------
>
>     stage('Quality Gate') {
>
>       steps {
>
>         sh 'echo "Sonar Analysis"'
>
>         withSonarQubeEnv('http://myserver') 
>
>         waitForQualityGate()
>
>
>       }
>
>     }
>
> -----------------
>
>    stage('Quality Gate') {
>
>       steps {
>
>         sh 'echo "Sonar Analysis"'
>
>         withSonarQubeEnv('http:myserver') 
>
>         def qualitygate = waitForQualityGate()
>
>         if (qualitygate.status != "OK") {
>
>          error "Pipeline aborted due to quality gate coverage failure: 
> ${qualitygate.status}"
>
>       }
>
>     }
>
>
>
> ------------
>
>
> pipeline {
>
>   agent any
>
>       environment {
>
>         withSonarQubeEnv = 'http://myserver/'
>
>     }
>
>   stages {
>
>     stage('Build') {
>
> steps {
>
> sh 'mvn install  -Dsonar.login=test -Dsonar.password=test 
> -Dsonar.host.url=http:myserver/ sonar:sonar '
>
>   }
>
>   }
>
>     stage('Quality Gate') {
>
>       steps {
>
>         sh 'echo "Sonar Analysis"'
>
>         waitForQualityGate()
>
>     }
>
>   }
>
>
>
> ------------
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b3d5b002-87e3-4647-9e68-e74bebf3adf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to