8000 feat(api): add option always send vcs notification #4635 (#4644) · ovh/cds@3962a19 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 3962a19

Browse files
bnjjjyesnault
authored andcommitted
feat(api): add option always send vcs notification #4635 (#4644)
Signed-off-by: Benjamin Coenen <benjamin.coenen@corp.ovh.com>
1 parent 0534b2d commit 3962a19

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

engine/api/workflow/workflow_run_event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ func sendVCSEventStatus(ctx context.Context, db gorp.SqlExecutor, store cache.St
336336
}
337337

338338
//Send comment on pull request
339-
if nodeRun.Status == sdk.StatusFail.String() || nodeRun.Status == sdk.StatusStopped.String() {
339+
if nodeRun.Status == sdk.StatusFail.String() || nodeRun.Status == sdk.StatusStopped.String() || notif.Settings.OnSuccess == sdk.UserNotificationAlways {
340340
for _, pr := range prs {
341341
if pr.Head.Branch.DisplayID == nodeRun.VCSBranch && pr.Head.Branch.LatestCommit == nodeRun.VCSHash && !pr.Merged && !pr.Closed {
342342
if err := client.PullRequestComment(ctx, app.RepositoryFullname, pr.ID, report); err != nil {

ui/src/app/views/workflow/show/notification/form/workflow.notification.form.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class WorkflowNotificationFormComponent implements OnInit {
3636
notifOnFailure: Array<string>;
3737
selectedUsers: string;
3838
commentEnabled = true;
39+
alwaysSend = true;
3940
nodeError = false;
4041
loadingNotifTemplate = false;
4142
triggerConditions: WorkflowTriggerConditionCache;
@@ -92,6 +93,7 @@ export class WorkflowNotificationFormComponent implements OnInit {
9293

9394
if (this.notification && this.notification.type === 'vcs') {
9495
this.commentEnabled = !this.notification.settings.template.disable_comment;
96+
this.alwaysSend = this.notification.settings.on_success === 'always';
9597
}
9698

9799
}
@@ -119,6 +121,11 @@ export class WorkflowNotificationFormComponent implements OnInit {
119121
}
120122
if (this.notification.type === 'vcs') {
121123
this.notification.settings.template.disable_comment = !this.commentEnabled;
124+
if (this.alwaysSend) {
125+
this.notification.settings.on_success = 'always';
126+
} else {
127+
this.notification.settings.on_success = null;
128+
}
122129
}
123130
this.updatedNotification.emit(this.notification);
124131
}

ui/src/app/views/workflow/show/notification/form/workflow.notifications.form.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@
9696
{{ 'workflow_notification_vcs_comment_enabled' | translate}}
9797
</sui-checkbox>
9898
</div>
99+
<div class="field">
100+
<sui-checkbox class="toggle no-mt" name="alwaysSend" [(ngModel)]="alwaysSend"
101+
[isDisabled]="!commentEnabled">
102+
{{ 'workflow_notification_vcs_comment_always' | translate}}
103+
</sui-checkbox>
104+
</div>
99105
<div class="field">
100106
<label>{{ 'workflow_notification_vcs_pr_comment_body' | translate }}</label>
101107
<textarea type="text" class="ui input" [(ngModel)]="notification.settings.template.body"
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
.centered {
2-
text-align: center;
2+
text-align: center;
33
}
4+
45
sui-checkbox {
5-
margin-top: 32px;
6-
}
6+
margin-top: 32px;
7+
8+
&.no-mt {
9+
margin-top: 0px;
10+
}
11+
}

ui/src/assets/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@
831831
"workflow_notification_form": "Add a notification",
832832
"workflow_notification_copy": "Copy",
833833
"workflow_notification_vcs_comment_enabled": "Pull-request's comment enabled",
834+
"workflow_notification_vcs_comment_always": "Always send",
834835
"workflow_notification_vcs_pr_comment_body": "Pull-request's comment body",
835836
"workflow_notification_explanation": "_A user notification can be useful to report the status of a workflow according to its status. Each pipeline in a workflow can be notified based on status in 'Success', 'Fail' or status change. The message sent to the recipients can be set using [CDS variables] (https://ovh.github.io/cds/docs/concepts/variables/). E-mail notifications can also contain HTML, cf. [User Notifications] documentation (https://ovh.github.io/cds/docs/concepts/workflow/notifications/) ._",
836837
"workflow_event_explanation": "_Here you can configure one or more integrations of type `Event`. This allows you to send all technical data in a backend to make it accessible by third-party applications such as Kafka or ElasticSearch. See the [Event Notifications] (https://ovh.github.io/cds/docs/concepts/workflow/notifications/) documentation for more information._",
@@ -895,4 +896,4 @@
895896
"workflow_error_unknown_key_description": "Key not found, please check that your all keys mentioned really exist. Or you can check if your SSH key which you mentioned in your application settings for your git repository is always valid and added on your git repository to have at least READ access.",
896897
"workflow_error_bad_vcs_strategy_title": "Bad VCS settings on application",
897898
"workflow_error_bad_vcs_strategy_description": "Please check if your SSH key which you mentioned in your application settings for your git repository is always valid and added on your git repository to have at least READ access. You can also check that you have a SSH key mentioned if you selected SSH mode on your application."
898-
}
899+
}

ui/src/assets/i18n/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@
831831
"workflow_notification_form": "Ajouter une notification",
832832
"workflow_notification_copy": "Copié",
833833
"workflow_notification_vcs_comment_enabled": "Commentaire de pull-request activé",
834+
"workflow_notification_vcs_comment_always": "Toujours envoyer",
834835
"workflow_notification_vcs_pr_comment_body": "Contenu du commentaire de pull-request",
835836
"workflow_notification_explanation": "_Une notification utilisateur peut être utile pour signaler le status d'un workflow en fonction de son état. Chaque pipeline d'un workflow peut donner lieu à une notification en fonction de sont statut en `Succès`, `En Echec` ou sur changement de statut. Le message envoyé aux destinataires peut être paramétré à l'aide de [variables CDS](https://ovh.github.io/cds/docs/concepts/variables/). Les notifications de type mail peuvent également contenir du HTML, cf. documentation [User Notifications](https://ovh.github.io/cds/docs/concepts/workflow/notifications/)._",
836837
"workflow_event_explanation": "_Vous pouvez configurer ici une ou plusieurs intégrations de type `Event`. Cela vous permet d'envoyer toutes les données techniques dans un backend afin de les rendre accessibles par des applications tierces telles que Kafka ou ElasticSearch. Consultez la documentation [Event Notifications](https://ovh.github.io/cds/docs/concepts/workflow/notifications/) pour plus d'informations._",
@@ -895,4 +896,4 @@
895896
"workflow_error_unknown_key_description": "Veuillez vérifier que la clé SSH avec laquelle vous avez lié votre application à votre dépôt git est bien active et indiqué sur votre dépôt git pour avoir les accès",
896897
"workflow_error_bad_vcs_strategy_title": "Mauvaise configuration des paramètres VCS de votre application",
897898
"workflow_error_bad_vcs_strategy_description": "Veuillez vérifier que la clé SSH avec laquelle vous avez lié votre application à votre dépôt git est bien active et indiqué sur votre dépôt git pour avoir les accès. Veuillez aussi vérifier que vous ayez bien une clé ssh de mentionnée dans votre fichier yaml d'application pointant sur votre dépôt git si vous avez mis le mode de clone SSH."
898-
}
899+
}

0 commit comments

Comments
 (0)
0