Skip to content

Commit 2800a84

Browse files
committed
merge master
2 parents 2e8ee28 + 598d6f3 commit 2800a84

File tree

5 files changed

+82
-34
lines changed

5 files changed

+82
-34
lines changed

README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
flow-platform-x
2-
============
1+
<h3 align="center">
2+
<a href="https://flowci.github.io">
3+
<img src="https://github.com/FlowCI/docs/raw/master/src/icon.png" alt="fastlane Logo" width="100">
4+
</a>
5+
</h3>
36

4-
[![LICENSE](https://img.shields.io/github/license/pingcap/tidb.svg)](https://github.com/pingcap/tidb/blob/master/LICENSE)
7+
<h3 align="center">A powerful and user-friendly CI/CD server</h3>
58

6-
Powerful and user-friendly CI/CD server
9+
<p align="center">
10+
<a href="https://github.com/FlowCI/docs/blob/master/LICENSE"><img src="https://img.shields.io/github/license/flowci/flow-core-x"></a>
11+
<a href="https://github.com/FlowCI/flow-core-x/releases/"><img src="https://img.shields.io/github/v/release/flowci/flow-core-x"></a>
12+
</p>
713

8-
- Getting started within a minute &nbsp; :tada:
14+
## Key Features
915

10-
- Simple YAML configuration and templates &nbsp; :ghost:
16+
- Zero configuration, can be getting started within a minute
1117

12-
- Elastic Agents to speed up build &nbsp; :rocket:
18+
- Simple YAML configuration and templates
1319

14-
- Online TTY to debug your job in time &nbsp; :shell:
20+
- Elastic agents to speed up build
1521

16-
- Flexible plugins &nbsp; :electric_plug:
22+
- Online TTY to debug your job in time
1723

18-
- Run steps either on any docker images or native os &nbsp; :computer:
24+
- Flexible plugins
1925

20-
## [Document](./en/index.md) | [中文文档](./zh/index.md)
26+
- Run steps either on any docker images or native os
2127

22-
## [Templates (maven, npm, golang..)](./en/index.md)
28+
## Document
2329

24-
## Quick Start
30+
[English](https://github.com/FlowCI/docs/tree/master/en/index.md) | [中文文档](https://github.com/FlowCI/docs/tree/master/cn/index.md)
31+
32+
## Templates
33+
34+
[maven, npm, golang, ruby, android and more](https://github.com/FlowCI/templates)
35+
36+
## Installation
2537

2638
> [Docker](https://docs.docker.com/install/) & [Docker-Compose](https://docs.docker.com/compose/install/) are required
2739
@@ -31,4 +43,8 @@ cd flow-docker
3143
./server.sh start
3244
```
3345

46+
## Preview
47+
3448
![demo](https://github.com/FlowCI/docs/raw/master/src/demo.gif)
49+
50+
![tty](https://github.com/FlowCI/docs/raw/master/src/step_tty.gif)

core/src/main/java/com/flowci/core/common/config/AppConfig.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
import com.flowci.core.common.helper.ThreadHelper;
2323
import com.flowci.util.FileHelper;
2424
import lombok.extern.log4j.Log4j2;
25-
import org.apache.http.client.HttpClient;
26-
import org.apache.http.client.config.RequestConfig;
27-
import org.apache.http.impl.client.HttpClientBuilder;
2825
import org.springframework.beans.factory.annotation.Autowired;
2926
import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
3027
import org.springframework.cache.annotation.EnableCaching;
@@ -82,18 +79,6 @@ public ObjectMapper objectMapper() {
8279
return JacksonHelper.create();
8380
}
8481

85-
@Bean("httpClient")
86-
public HttpClient httpClient() {
87-
int timeout = 10 * 1000;
88-
RequestConfig config = RequestConfig.custom()
89-
.setConnectTimeout(timeout)
90-
.setConnectionRequestTimeout(timeout)
91-
.setSocketTimeout(timeout)
92-
.build();
93-
94-
return HttpClientBuilder.create().setDefaultRequestConfig(config).build();
95-
}
96-
9782
@Bean("appTaskExecutor")
9883
public TaskExecutor getAppTaskExecutor() {
9984
return ThreadHelper.createTaskExecutor(100, 100, 50, "app-task-");
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.flowci.core.common.manager;
2+
3+
import org.apache.http.HttpResponse;
4+
import org.apache.http.client.HttpClient;
5+
import org.apache.http.client.config.RequestConfig;
6+
import org.apache.http.client.methods.HttpGet;
7+
import org.apache.http.impl.client.HttpClientBuilder;
8+
import org.apache.http.util.EntityUtils;
9+
import org.springframework.stereotype.Component;
10+
11+
import javax.annotation.PostConstruct;
12+
import java.io.IOException;
13+
14+
@Component("httpManager")
15+
public class HttpRequestManager {
16+
17+
private final static int DefaultTimeout = 30 * 1000;
18+
19+
private final static String DefaultUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36";
20+
21+
private HttpClient client;
22+
23+
@PostConstruct
24+
public void init() {
25+
RequestConfig config = RequestConfig.custom()
26+
.setConnectTimeout(DefaultTimeout)
27+
.setConnectionRequestTimeout(DefaultTimeout)
28+
.setSocketTimeout(DefaultTimeout)
29+
.build();
30+
client = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
31+
}
32+
33+
public String get(String url) throws IOException {
34+
HttpGet request = new HttpGet(url);
35+
request.setHeader("User-Agent", DefaultUserAgent);
36+
37+
HttpResponse execute = client.execute(request);
38+
return EntityUtils.toString(execute.getEntity());
39+
}
40+
}

core/src/main/java/com/flowci/core/flow/config/FlowConfig.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.fasterxml.jackson.databind.ObjectMapper;
2121
import com.flowci.core.common.config.AppProperties;
2222
import com.flowci.core.common.helper.CacheHelper;
23+
import com.flowci.core.common.manager.HttpRequestManager;
2324
import com.flowci.core.flow.domain.Template;
2425
import com.github.benmanes.caffeine.cache.Cache;
2526
import lombok.extern.log4j.Log4j2;
@@ -30,7 +31,6 @@
3031
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
3132

3233
import java.io.IOException;
33-
import java.net.URL;
3434
import java.util.List;
3535

3636
/**
@@ -52,12 +52,14 @@ public Cache<String, List<String>> gitBranchCache() {
5252
}
5353

5454
@Bean("templates")
55-
public List<Template> getTemplates() throws IOException {
55+
public List<Template> getTemplates(HttpRequestManager httpManager) throws IOException {
56+
String body = httpManager.get(flowProperties.getTemplatesUrl());
57+
5658
TypeReference<List<Template>> typeRef = new TypeReference<List<Template>>() {
5759
};
58-
String url = flowProperties.getTemplatesUrl();
59-
List<Template> list = objectMapper.readValue(new URL(url), typeRef);
60-
log.info("Templates is loaded from {}", url);
60+
61+
List<Template> list = objectMapper.readValue(body, typeRef);
62+
log.info("Templates is loaded from {}", flowProperties.getTemplatesUrl());
6163
return list;
6264
}
6365

core/src/main/java/com/flowci/core/plugin/service/PluginServiceImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.fasterxml.jackson.databind.ObjectMapper;
2121
import com.flowci.core.common.config.AppProperties;
2222
import com.flowci.core.common.git.GitClient;
23+
import com.flowci.core.common.manager.HttpRequestManager;
2324
import com.flowci.core.common.manager.VarManager;
2425
import com.flowci.core.plugin.dao.PluginDao;
2526
import com.flowci.core.plugin.domain.Plugin;
@@ -90,6 +91,9 @@ public class PluginServiceImpl implements PluginService {
9091
@Autowired
9192
private VarManager varManager;
9293

94+
@Autowired
95+
private HttpRequestManager httpManager;
96+
9397
private final Object reloadLock = new Object();
9498

9599
@EventListener
@@ -191,7 +195,8 @@ public Path getDir(Plugin plugin) {
191195
public List<PluginRepoInfo> load(String repoUrl) {
192196
try {
193197
repoUrl = repoUrl + "?t=" + Instant.now().toEpochMilli();
194-
return objectMapper.readValue(new URL(repoUrl), RepoListType);
198+
String body = httpManager.get(repoUrl);
199+
return objectMapper.readValue(body, RepoListType);
195200
} catch (Throwable e) {
196201
log.warn("Unable to load plugin repo '{}' : {}", repoUrl, e.getMessage());
197202
return Collections.emptyList();

0 commit comments

Comments
 (0)