7 个月 后

大佬 我按照你这种方式 是可以加载到sonar 但是我sonar加载完后报错
#####报错信息
No previous SonarQube analysis found on this pipeline execution. Please use the ‘withSonarQubeEnv’ wrapper to run your analysis.

######
我的通过kubesphere生成的Jenkinsfile

stage('Code Analysis') {

  agent none

  steps {

    container('maven') {

      withCredentials([string(credentialsId : 'sonar' ,variable : 'SONAR_TOKEN' ,)]) {

        withSonarQubeEnv('sonar') {

          sh '''mvn -B sonar:sonar -Dsonar.login=$SONAR_TOKEN -Dsonar.projectKey=demo-test 

'''

          timeout(unit: 'MINUTES', activity: true, time: 2) {

            waitForQualityGate 'true'

          }

        }

      }

    }

  }

}

    yudong大佬 你好!
    #####我配置相关的token

    ####我在Jenkins里面加入了相关凭证

    ####我在sonar上面也可以看到我上传的代码包

    ###我的流水线配置

      1934801322
      看报错是 等待代码检查 这一步报错了,麻烦参考这个截图修改下,然后在运行下流水线;

        yudong
        大佬 我再次修改后

        ###报错信息

        ###这个Jenkinsfile 是我通过图像构建自动生成的

          yudong

          ####调整后的timeout

          ####调整后报错还是没有改变

          ####图像化步骤

            yudong
            ####修改后配置

            ####日志信息

            现在这样得话 第一个阶段就不能过去了

              1934801322 这个格式还是没有改,在手动编辑下 jenkinsfile ,修改我上面截图的那一段;

                yudong

                大佬 我这样修改后 就找不到文件呢

                ####配置信息

                ####报错信息

                  1934801322 哦,这个文件可以不用,这个 mvn 命令还用你之前的;只不过格式改下:

                                  container('maven') {
                                      withCredentials([string(credentialsId: "sonar", variable: 'SONAR_TOKEN')]) {
                                          withSonarQubeEnv('sonar') {
                                              sh '''mvn sonar:sonar -Dsonar.login=$SONAR_TOKEN'''
                                          }
                                      }
                                      timeout(time: 1, unit: 'HOURS') {
                                          waitForQualityGate abortPipeline: true
                                      }
                                  }

                    yudong
                    ####报错信息

                    ####配置信息

                    stage('Code Analysis') {
                    
                      agent none
                    
                      steps {
                    
                        container('maven') {
                    
                          withCredentials([string(credentialsId : 'sonar' ,variable : 'SONAR_TOKEN' ,)]) {
                    
                            withSonarQubeEnv('sonar') {
                    
                              sh '''mvn  sonar:sonar  -Dsonar.login=$SONAR_TOKEN 

                    '''

                              timeout(time: 1, unit: 'HOURS') {
                    
                                waitForQualityGate abortPipeline: 'true'
                    
                              }
                    
                            }
                    
                          }
                    
                        }
                    
                      }
                    
                    }

                    ####目前就是一直卡在 这个报错

                    No previous SonarQube analysis found on this pipeline execution. Please use the ‘withSonarQubeEnv’ wrapper to run your analysis.