|
|
@@ -9,7 +9,6 @@ import cn.seecoder.build.server.service.facade.jenkins.JenkinsServerApi;
|
|
|
import cn.seecoder.build.server.service.model.converter.TestResultConvertor;
|
|
|
import cn.seecoder.build.server.util.LoggerUtil;
|
|
|
import cn.seecoder.build.server.util.ServiceException;
|
|
|
-
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.offbytwo.jenkins.JenkinsServer;
|
|
|
import com.offbytwo.jenkins.model.*;
|
|
|
@@ -19,7 +18,6 @@ import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
import java.net.URISyntaxException;
|
|
|
@@ -32,10 +30,11 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
private static final Logger logger = LoggerUtil.getLogger(JenkinsApiImpl.class);
|
|
|
private final JenkinsServer server;
|
|
|
private final JenkinsInternalApi jenkinsInternalApi;
|
|
|
+
|
|
|
@Autowired
|
|
|
public JenkinsApiImpl(JenkinsInternalApi jenkinsInternalApi, JenkinsServerApi jenkinsServerApi) {
|
|
|
this.jenkinsInternalApi = jenkinsInternalApi;
|
|
|
- this.server=jenkinsServerApi.getJenkinsServer();
|
|
|
+ this.server = jenkinsServerApi.getJenkinsServer();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -45,6 +44,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
server.createJob(jobName, configTemplate);
|
|
|
} catch (IOException e) {
|
|
|
logger.error("createJob exception={}, jobName={}, configTemplate={}", e, jobName, configTemplate);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -63,7 +63,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
JobWithDetails jobWithDetails = server.getJob(jobName);
|
|
|
logger.info("getJobWithDetails成功");
|
|
|
reference = jenkinsInternalApi.invokeBuild(jobWithDetails, params);
|
|
|
- logger.info("invokeBuild成功 referenceUrl:"+reference.getQueueItemUrlPart());
|
|
|
+ logger.info("invokeBuild成功 referenceUrl:" + reference.getQueueItemUrlPart());
|
|
|
QueueItem item = server.getQueueItem(reference);
|
|
|
logger.info("第一次getQueueItem成功");
|
|
|
while (item.getExecutable() == null) {
|
|
|
@@ -78,6 +78,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
return item.getExecutable().getNumber().intValue();
|
|
|
} catch (IOException e) {
|
|
|
logger.error("invokeBuild exception={}, jobName={}, params={}", e, jobName, params);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -88,6 +89,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
server.deleteJob(jobName);
|
|
|
} catch (IOException e) {
|
|
|
logger.error("deleteJob exception={}, jobName={}", e, jobName);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -99,6 +101,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
return jenkinsInternalApi.get(build, path, cls);
|
|
|
} catch (IOException e) {
|
|
|
logger.error("get exception={}, path={}", e, path);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -109,6 +112,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
return jenkinsInternalApi.get(build, path);
|
|
|
} catch (IOException e) {
|
|
|
logger.error("get exception={}, path={}", e, path);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -148,6 +152,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
return buildDetailsVO;
|
|
|
} catch (IOException e) {
|
|
|
logger.error("getBuildDetailsVO exception={}, jobName={}, buildId={}", e, jobName, buildId);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -171,6 +176,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
return buildWithDetails;
|
|
|
} catch (IOException e) {
|
|
|
logger.error("getBuildDetails exception={}, jobName={}, buildId={}, waitFinished={}", e, jobName, buildId, waitFinished);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -215,9 +221,11 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
}
|
|
|
} catch (DocumentException e) {
|
|
|
logger.error("documentParseText exception=" + e);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
} catch (IOException e) {
|
|
|
logger.error("writeArtifact exception=" + e);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
|
|
|
}
|
|
|
@@ -233,6 +241,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
return jenkinsInternalApi.downloadArtifact(build, relativePath);
|
|
|
} catch (IOException | URISyntaxException e) {
|
|
|
logger.error("downloadArtifact exception={}, relativePath={}", e, relativePath);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -243,6 +252,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
return jenkinsInternalApi.getTestResult(buildWithDetails);
|
|
|
} catch (IOException e) {
|
|
|
logger.error("getTestResult exception=" + e);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
@@ -253,6 +263,7 @@ public class JenkinsApiImpl implements JenkinsApi {
|
|
|
return jenkinsInternalApi.getCoverageResult(buildWithDetails);
|
|
|
} catch (IOException e) {
|
|
|
logger.error("getCoverageResult exception=" + e);
|
|
|
+ e.printStackTrace();
|
|
|
throw new ServiceException("101", e.getMessage());
|
|
|
}
|
|
|
}
|