Merge branch 'dev' into service_port
This commit is contained in:
commit
3c94525e1a
|
@ -777,9 +777,8 @@ public class GameService {
|
|||
}
|
||||
}
|
||||
|
||||
public void gitCredentialStore() throws GameException {
|
||||
String gitIP = appConfig.getGitIP();
|
||||
String cmd = "echo -e 'protocol=http\nhost="+ gitIP +"' | git credential-store get";
|
||||
public void gitCredentialStore(String gitIP, String protocol) throws GameException {
|
||||
String cmd = "echo -e 'protocol="+ protocol +"\nhost="+ gitIP +"' | git credential-store get";
|
||||
JSONObject result = ShellUtil.executeAndGetExitStatus(cmd, 3);
|
||||
if (result.getInteger("exitStatus") != 0) {
|
||||
logger.error("获取git凭证失败!gitIP: {} e:{}", gitIP, result);
|
||||
|
@ -789,17 +788,24 @@ public class GameService {
|
|||
// 无凭证或者凭证用户密码不匹配则设置凭证
|
||||
String username = appConfig.getGitUsername();
|
||||
String password = appConfig.getGitPassword();
|
||||
if (StringUtils.isEmpty(out) || !out.contains(username) || !out.contains(password)) {
|
||||
logger.debug("获取git凭证信息: {}", out);
|
||||
setGitCredential(gitIP, username, password);
|
||||
logger.debug("获取git凭证信息: {}", out);
|
||||
if (StringUtils.isEmpty(out)) {
|
||||
String setCmd = "git config --global user.email educoder@163.com" +
|
||||
" && git config --global user.name educoder" +
|
||||
" && git config --global credential.helper store" +
|
||||
" && echo -e 'protocol="+ protocol +"\nhost="+ gitIP +"\nusername="+ username +"\npassword="+ password +"' | git credential approve";
|
||||
setGitCredential(setCmd, gitIP);
|
||||
return;
|
||||
}
|
||||
if (!out.contains(username) || !out.contains(password)) {
|
||||
String setCmd = "git config --global user.email educoder@163.com" +
|
||||
" && git config --global user.name educoder" +
|
||||
" && echo -e 'protocol="+ protocol +"\nhost="+ gitIP +"\nusername="+ username +"\npassword="+ password +"' | git credential approve";
|
||||
setGitCredential(setCmd, gitIP);
|
||||
}
|
||||
}
|
||||
|
||||
private void setGitCredential(String gitIP, String username, String password) throws GameException {
|
||||
String cmd = "git config --global user.email educoder@163.com" +
|
||||
" && git config --global user.name educoder" +
|
||||
" && git config --global credential.helper store" +
|
||||
" && echo -e 'protocol=http\nhost="+ gitIP +"\nusername="+ username +"\npassword="+ password +"' | git credential approve";
|
||||
private void setGitCredential(String cmd, String gitIP) throws GameException {
|
||||
JSONObject result = ShellUtil.executeAndGetExitStatus(cmd, 3);
|
||||
if (result.getInteger("exitStatus") != 0) {
|
||||
logger.error("设置git凭证失败!gitIP: {} e:{} ", gitIP, result);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.educoder.bridge.game.task;
|
||||
|
||||
import com.educoder.bridge.common.settings.AppConfig;
|
||||
import com.educoder.bridge.game.exception.GameException;
|
||||
import com.educoder.bridge.game.service.GameService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -13,11 +14,16 @@ import javax.annotation.PostConstruct;
|
|||
@Component
|
||||
public class GitInitTask {
|
||||
|
||||
@Autowired
|
||||
private AppConfig appConfig;
|
||||
@Autowired
|
||||
private GameService gameService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() throws GameException {
|
||||
gameService.gitCredentialStore();
|
||||
String gitIP = appConfig.getGitIP();
|
||||
gameService.gitCredentialStore(gitIP, "http");
|
||||
String gitDomainName = "git.educode.net";
|
||||
gameService.gitCredentialStore(gitDomainName, "https");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ gpuImage=ubuntu-nvidia
|
|||
|
||||
#git\u7528\u6237\u540d\u53ca\u5bc6\u7801
|
||||
gitUsername=edugit
|
||||
gitPassword=xinedugit%23
|
||||
gitPassword=xinedugit#
|
||||
|
||||
# mysql
|
||||
jdbc.driver=com.mysql.jdbc.Driver
|
||||
|
@ -79,4 +79,4 @@ bootstrapServersConfig=172.16.95.15:9092
|
|||
useMq=true
|
||||
openPodReuse=true
|
||||
|
||||
netNames=eth0,ens32
|
||||
netNames=eth0,ens32
|
||||
|
|
Loading…
Reference in New Issue