Merge pull request #1006 from yangkaa/master-maven

Fix Bug: modified get maven setting logic
This commit is contained in:
barnettZQG 2021-05-28 09:14:45 +08:00 committed by GitHub
commit 0a88a94f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 7 deletions

View File

@ -442,11 +442,14 @@ func (s *slugBuild) runBuildJob(re *Request) error {
if mavenSettingName != "" && re.Lang.String() == code.JavaMaven.String() {
if setting := jobc.GetJobController().GetLanguageBuildSetting(re.Ctx, code.JavaMaven, mavenSettingName); setting != "" {
mavenSettingConfigName = setting
}
}
if mavenSettingConfigName == "" {
if settingName := jobc.GetJobController().GetDefaultLanguageBuildSetting(re.Ctx, code.JavaMaven); settingName != "" {
mavenSettingConfigName = settingName
} else {
logrus.Warnf("maven setting config %s not found", mavenSettingName)
}
} else if settingName := jobc.GetJobController().GetDefaultLanguageBuildSetting(re.Ctx, code.JavaMaven); settingName != "" {
mavenSettingConfigName = settingName
}
if mavenSettingConfigName != "" {
podSpec.Volumes = append(podSpec.Volumes, corev1.Volume{

View File

@ -249,12 +249,22 @@ func (c *controller) GetDefaultLanguageBuildSetting(ctx context.Context, lang co
LabelSelector: "default=true",
})
if err != nil {
logrus.Errorf("get default maven setting configmap failure %s", err.Error())
logrus.Errorf("get default maven setting configmap failure %s", err.Error())
return ""
}
if config != nil {
for _, c := range config.Items {
return c.Name
}
for _, c := range config.Items {
return c.Name
}
// Use the first maven setting when there is no default Maven configuration
allConfig, err := c.KubeClient.CoreV1().ConfigMaps(c.namespace).List(ctx, metav1.ListOptions{
LabelSelector: "configtype=mavensetting",
})
if err != nil {
logrus.Errorf("get all maven setting configmap failure %s", err.Error())
return ""
}
for _, ac := range allConfig.Items {
return ac.Name
}
return ""
}