Управление уведомлениями сброк в тимсити
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-teamcity.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>
|
@ -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")
|
||||
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.teamcity.core.domain.ServiceNotify;
|
||||
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.service.BuildShortService;
|
||||
import org.sadtech.bot.vcs.teamcity.core.service.TeamcitySettingService;
|
||||
import org.sadtech.bot.vcs.teamcity.sdk.BuildStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Set;
|
||||
@ -41,16 +43,23 @@ public class BuildShortServiceImpl extends AbstractSimpleManagerService<BuildSho
|
||||
final BuildShort newBuildShort = buildShortRepository.save(buildShort);
|
||||
|
||||
teamcitySettingService.getAllByProjectId(buildShort.getProjectId())
|
||||
.forEach(
|
||||
teamcitySetting -> notifyService.send(
|
||||
.forEach(teamcitySetting -> sendNotification(teamcitySetting, buildShort));
|
||||
|
||||
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()
|
||||
.buildShort(buildShort)
|
||||
.chatId(teamcitySetting.getChatId())
|
||||
.build()
|
||||
)
|
||||
);
|
||||
|
||||
return newBuildShort;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user