Explorar el Código

test:补充直接调用JenkinsServer的测试

TianChenjiang hace 4 años
padre
commit
e2ec1d5fa0

+ 13 - 1
seecoder-build-client/src/test/java/cn/seecoder/client/SeecoderBuildClientTest.java

@@ -3,6 +3,7 @@ package cn.seecoder.client;
 import cn.seecoder.build.client.SeecoderBuildClient;
 import cn.seecoder.build.model.vo.BuildDetailsVO;
 import cn.seecoder.build.model.vo.PipelineVO;
+import com.offbytwo.jenkins.JenkinsServer;
 import org.apache.commons.io.IOUtils;
 import org.junit.Assert;
 import org.junit.Before;
@@ -10,6 +11,7 @@ import org.junit.Test;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.List;
@@ -22,10 +24,20 @@ public class SeecoderBuildClientTest {
 
     private String template;
 
+    private JenkinsServer jenkinsServer;
+
     @Before
     public void init() throws URISyntaxException, IOException {
         client = new SeecoderBuildClient("https://seecoder-build.seec.seecoder.cn", "3b861b052fd085887b5462fe5ae0c3a916b2c281d776a4d87e7bd5572ad24608");
         template = IOUtils.readLines(getClass().getClassLoader().getResourceAsStream("config.xml")).stream().collect(Collectors.joining("\n"));
+        //用于测试jenkins服务器
+        this.jenkinsServer = new JenkinsServer(new URI("https://seecoder-build-jenkins.seec.seecoder.cn"), "admin", "11cf3c7f64d8203ea45a07320a2a416bce");
+    }
+
+    @Test
+    public void getJob() throws IOException {
+//        jenkinsServer.createJob("test-pipeline2",template);
+        System.out.println(jenkinsServer.getJobs());
     }
 
     @Test
@@ -98,7 +110,7 @@ public class SeecoderBuildClientTest {
         params.put("EXECUTE_SHELL", "mvn cobertura:cobertura");
         params.put("PROB_TARGET", "COVERAGE");
         params.put("JAR_ARTIFACT", "org.jacoco.examples.maven.java-1.0-SNAPSHOT.jar");
-        System.out.println(client.invokeBuild(1, "coder-test", params));
+        System.out.println(client.invokeBuild(1, "test-pipeline2", params));
     }
     @Test
     public void getEntity() {

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

@@ -94,7 +94,7 @@
             environment name: 'PROB_TARGET', value: 'COVERAGE'
             }
             steps {
-            cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage-reports/*.xml', conditionalCoverageTargets: '70, 0, 0', failNoReports: false, failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
+            publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')]
             }
             }
             stage('Collect Mutation Report') {
@@ -118,4 +118,4 @@
     </definition>
     <triggers/>
     <disabled>false</disabled>
-</flow-definition>
+</flow-definition>