Jenkins file with kubernenetes sonar build stage

10/25/2019

I am using Angular application for front end code, along with jenkins file docker image push into container registry after that we will deploy the code into the Kubernetes cluster.

stage('Deploy') {
        container('kubectl') {
          withCredentials([file(credentialsId: 'KUBE_CONFIG', variable: 'KUBE_CONFIG')]) {
            def kubectl
            echo 'deploy to deployment!'
              if(gitBranch == "master") {
                 kubectl = "kubectl --kubeconfig=${KUBE_CONFIG} --context=K8sCluster-testenv"
                echo 'deploy to testenv environment!'
                sh "${kubectl} apply -f ./infrastructure/testenv -n=testenv"
                messageInfo = "app is deployed to testenv"             
              }

Now the question is, I need to add one more build stage to run sonar scanner to check the code quality after the successful deployment.

can you please someone help me with this.

-- Anji
kubernetes
sonarqube

0 Answers