-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
王灏
committed
May 5, 2023
1 parent
085c2a1
commit 108eea7
Showing
2 changed files
with
37 additions
and
14 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/java/io/choerodon/gitlab/app/task/GitlabConfigCommandRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.choerodon.gitlab.app.task; | ||
|
||
import org.gitlab4j.api.GitLabApi; | ||
import org.gitlab4j.api.models.ApplicationSettings; | ||
import org.gitlab4j.api.models.Setting; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* 〈功能简述〉 | ||
* 〈〉 | ||
* | ||
* @author wanghao | ||
* @since 2023/5/5 14:53 | ||
*/ | ||
@Component | ||
public class GitlabConfigCommandRunner implements CommandLineRunner { | ||
|
||
@Value("${gitlab.url}") | ||
private String url; | ||
|
||
@Value("${gitlab.privateToken}") | ||
private String privateToken; | ||
|
||
@Override | ||
public void run(String... args) throws Exception { | ||
GitLabApi gitLabApi = new GitLabApi(url, privateToken); | ||
ApplicationSettings applicationSettings = gitLabApi.getApplicationSettingsApi().getApplicationSettings(); | ||
if (!Boolean.TRUE.equals(applicationSettings.getSetting(Setting.ALLOW_LOCAL_REQUESTS_FROM_WEB_HOOKS_AND_SERVICES))) { | ||
gitLabApi.getApplicationSettingsApi().updateApplicationSetting(Setting.ALLOW_LOCAL_REQUESTS_FROM_WEB_HOOKS_AND_SERVICES, true); | ||
} | ||
if (!Boolean.TRUE.equals(applicationSettings.getSetting(Setting.ALLOW_LOCAL_REQUESTS_FROM_SYSTEM_HOOKS))) { | ||
gitLabApi.getApplicationSettingsApi().updateApplicationSetting(Setting.ALLOW_LOCAL_REQUESTS_FROM_SYSTEM_HOOKS, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters