Selaa lähdekoodia

chore: 修改默认pipeline

TianChenjiang 4 vuotta sitten
vanhempi
commit
eec2ce0420
1 muutettua tiedostoa jossa 106 lisäystä ja 38 poistoa
  1. 106 38
      seecoder-build-client/src/test/resources/config.xml

+ 106 - 38
seecoder-build-client/src/test/resources/config.xml

@@ -36,7 +36,61 @@
                     <trim>false</trim>
                 </hudson.model.TextParameterDefinition>
                 <hudson.model.TextParameterDefinition>
-                    <name>TARGET_JAR</name>
+                    <name>SONAEQUEBE_URL</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>SONARQUBE_URL</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>SONARQUBE_LOGIN</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>SONARQUBE_PASSWORD</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>SONARQUBE_PROJECT</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>PROBLEM_DIR</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>EXCLUSIONS</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>SOURCES</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>BINARIES</name>
+                    <description/>
+                    <defaultValue/>
+                    <trim>false</trim>
+                </hudson.model.TextParameterDefinition>
+                <hudson.model.TextParameterDefinition>
+                    <name>CODE_ANALYSIS_SWITCH</name>
                     <description/>
                     <defaultValue/>
                     <trim>false</trim>
@@ -46,73 +100,87 @@
     </properties>
     <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps@2.53">
         <script>
-            pipeline {
-            agent any
-            stages {
-            stage(&apos;Clean Workspace&apos;) {
+pipeline {
+    agent any
+    stages {
+        stage(&apos;Clean Workspace&apos;) {
             steps {
-            deleteDir()
-            }
+                deleteDir()
             }
-            stage(&apos;Pull Code&apos;) {
+        }
+        stage(&apos;Pull Code&apos;) {
             steps {
-            git credentialsId: &quot;MOOCODER&quot;, url: &quot;${GIT_URL}&quot;
+                git credentialsId: &quot;MOOCODER&quot;, url: &quot;${GIT_URL}&quot;
             }
-            }
-            stage(&apos;Reset Git HEAD&apos;) {
+        }
+        stage(&apos;Reset Git HEAD&apos;) {
             steps {
-            sh &quot;git reset --hard ${COMMIT_HASH}&quot;
+                sh &quot;git reset --hard ${COMMIT_HASH}&quot;
             }
+        }
+        stage('SonarQube'){
+            when {
+                environment name: &apos;CODE_ANALYSIS_SWITCH&apos;, value: &apos;true&apos;
             }
-            stage(&apos;Run Build&apos;) {
-            agent {
-            docker {
-            image &quot;${DOCKER_IMAGE}&quot;
-            args &apos;--cpus 1 -m 1G&apos;<!-- mount type=tmpfs,destination=/var/ws/tmp,tmpfs-size=134217728-->
-            reuseNode true
+            steps{
+                script{
+                    sonarqubeScanner = tool name: 'scanner_for_sonar'
+                }
+                withSonarQubeEnv('sonar') {
+                    sh "${sonarqubeScanner}/bin/sonar-scanner -Dsonar.projectKey=${SONARQUBE_PROJECT} -Dsonar.projectName=${SONARQUBE_PROJECT} -Dsonar.exclusions=$WORKSPACE/${PROBLEM_DIR}/${EXCLUSIONS} -Dsonar.sources=$WORKSPACE/${PROBLEM_DIR}/${SOURCES} -Dsonar.java.binaries=$WORKSPACE/${PROBLEM_DIR}/${BINARIES} -Dsonar.host.url=${SONARQUBE_URL} -Dsonar.login=${SONARQUBE_LOGIN} -Dsonar.password=${SONARQUBE_PASSWORD}"
+                }
             }
+        }
+        stage(&apos;Run Build&apos;) {
+            agent {
+                docker {
+                    image &quot;${DOCKER_IMAGE}&quot;
+                    args &apos;--network none --cpus 1 -m 1G -h localhost --mount type=tmpfs,destination=/var/ws/tmp,tmpfs-size=134217728&apos;
+                    reuseNode true
+                }
             }
             steps {
                 echo &apos;==CONSOLE OUTPUT BEGIN==&apos;
                 catchError {
-                    sh &quot;${EXECUTE_SHELL}&quot;
+                    timeout(1) {
+                        sh &quot;${EXECUTE_SHELL}&quot;
+                    }
                 }
-                archiveArtifacts allowEmptyArchive: true, artifacts: &apos;${TARGET_JAR}&apos;
                 echo &apos;==CONSOLE OUTPUT END==&apos;
             }
-            }
-            stage(&apos;Collect DLTest Report&apos;) {
+        }
+        stage(&apos;Collect Test Report&apos;) {
             when {
-            environment name: &apos;PROB_TARGET&apos;, value: &apos;TEST&apos;
+                environment name: &apos;PROB_TARGET&apos;, value: &apos;TEST&apos;
             }
             steps {
-            junit allowEmptyResults: true, testResults: &apos;test-reports/*.xml&apos;
+                junit allowEmptyResults: true, testResults: &apos;test-reports/*.xml&apos;
             }
-            }
-            stage(&apos;Collect Coverage Report&apos;) {
+        }
+        stage(&apos;Collect Coverage Report&apos;) {
             when {
-            environment name: &apos;PROB_TARGET&apos;, value: &apos;COVERAGE&apos;
+                environment name: &apos;PROB_TARGET&apos;, value: &apos;COVERAGE&apos;
             }
             steps {
             publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')]
             }
-            }
-            stage(&apos;Collect Mutation Report&apos;) {
+        }
+        stage(&apos;Collect Mutation Report&apos;) {
             when {
-            environment name: &apos;PROB_TARGET&apos;, value: &apos;MUTATION&apos;
+                environment name: &apos;PROB_TARGET&apos;, value: &apos;MUTATION&apos;
             }
             steps {
-            archiveArtifacts allowEmptyArchive: true, artifacts: &apos;mutation-reports/mutations.xml&apos;
-            }
-            }
+                archiveArtifacts allowEmptyArchive: true, artifacts: &apos;mutation-reports/mutations.xml&apos;
             }
-            post {
-            always {
+        }
+    }
+    post {
+        always {
             cleanWs()
             sh &apos;curl -o /dev/null -s -X POST -H &quot;X-Moocoder-Secret: ${MOOCODER_SECRET}&quot; &quot;${MOOCODER_HOST}/internal/notify/callback/${JOB_NAME}/${BUILD_NUMBER}&quot; || :&apos;
-            }
-            }
-            }
+        }
+    }
+}
         </script>
         <sandbox>true</sandbox>
     </definition>