Управление уведомлениями сброк в тимсити
This commit is contained in:
parent
76ca3e8406
commit
03ed80b7fd
@ -8,5 +8,6 @@
|
|||||||
<include file="liquibase/v.2.0.0/2020-09-20-setting-notify.xml"/>
|
<include file="liquibase/v.2.0.0/2020-09-20-setting-notify.xml"/>
|
||||||
<include file="liquibase/v.2.0.0/2020-09-20-teamcity.xml"/>
|
<include file="liquibase/v.2.0.0/2020-09-20-teamcity.xml"/>
|
||||||
<include file="liquibase/v.2.0.0/2020-10-01-rating.xml"/>
|
<include file="liquibase/v.2.0.0/2020-10-01-rating.xml"/>
|
||||||
|
<include file="liquibase/v.2.0.0/2020-10-02-add-column-status-teamcity.xml"/>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
@ -0,0 +1,19 @@
|
|||||||
|
<databaseChangeLog
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
|
||||||
|
|
||||||
|
<changeSet id="2020-10-02" author="upagge">
|
||||||
|
<addColumn tableName="teamcity_setting">
|
||||||
|
<column name="success" type="boolean">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="teamcity_setting">
|
||||||
|
<column name="failure" type="boolean">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
|
</databaseChangeLog>
|
@ -35,4 +35,10 @@ public class TeamcitySetting {
|
|||||||
@Column(name = "project_id")
|
@Column(name = "project_id")
|
||||||
private String projectId;
|
private String projectId;
|
||||||
|
|
||||||
|
@Column(name = "success")
|
||||||
|
private boolean success;
|
||||||
|
|
||||||
|
@Column(name = "failure")
|
||||||
|
private boolean failure;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,11 @@ import org.sadtech.basic.core.service.AbstractSimpleManagerService;
|
|||||||
import org.sadtech.bot.vcs.core.service.NotifyService;
|
import org.sadtech.bot.vcs.core.service.NotifyService;
|
||||||
import org.sadtech.bot.vcs.teamcity.core.domain.ServiceNotify;
|
import org.sadtech.bot.vcs.teamcity.core.domain.ServiceNotify;
|
||||||
import org.sadtech.bot.vcs.teamcity.core.domain.entity.BuildShort;
|
import org.sadtech.bot.vcs.teamcity.core.domain.entity.BuildShort;
|
||||||
|
import org.sadtech.bot.vcs.teamcity.core.domain.entity.TeamcitySetting;
|
||||||
import org.sadtech.bot.vcs.teamcity.core.repository.BuildShortRepository;
|
import org.sadtech.bot.vcs.teamcity.core.repository.BuildShortRepository;
|
||||||
import org.sadtech.bot.vcs.teamcity.core.service.BuildShortService;
|
import org.sadtech.bot.vcs.teamcity.core.service.BuildShortService;
|
||||||
import org.sadtech.bot.vcs.teamcity.core.service.TeamcitySettingService;
|
import org.sadtech.bot.vcs.teamcity.core.service.TeamcitySettingService;
|
||||||
|
import org.sadtech.bot.vcs.teamcity.sdk.BuildStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -41,16 +43,23 @@ public class BuildShortServiceImpl extends AbstractSimpleManagerService<BuildSho
|
|||||||
final BuildShort newBuildShort = buildShortRepository.save(buildShort);
|
final BuildShort newBuildShort = buildShortRepository.save(buildShort);
|
||||||
|
|
||||||
teamcitySettingService.getAllByProjectId(buildShort.getProjectId())
|
teamcitySettingService.getAllByProjectId(buildShort.getProjectId())
|
||||||
.forEach(
|
.forEach(teamcitySetting -> sendNotification(teamcitySetting, buildShort));
|
||||||
teamcitySetting -> notifyService.send(
|
|
||||||
|
return newBuildShort;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendNotification(TeamcitySetting teamcitySetting, BuildShort buildShort) {
|
||||||
|
if (
|
||||||
|
(teamcitySetting.isFailure() && BuildStatus.FAILURE.equals(buildShort.getStatus()))
|
||||||
|
|| (teamcitySetting.isSuccess() && BuildStatus.SUCCESS.equals(buildShort.getStatus()))
|
||||||
|
) {
|
||||||
|
notifyService.send(
|
||||||
ServiceNotify.builder()
|
ServiceNotify.builder()
|
||||||
.buildShort(buildShort)
|
.buildShort(buildShort)
|
||||||
.chatId(teamcitySetting.getChatId())
|
.chatId(teamcitySetting.getChatId())
|
||||||
.build()
|
.build()
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return newBuildShort;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user