@@ -500,11 +500,17 @@ pipeline {
500
500
return
501
501
}
502
502
503
+ if (! env. CHANGE_ID ) {
504
+ echo " Not a Pull request."
505
+ return
506
+ }
507
+
503
508
def issue = jiraGetIssue site : ' irontec.atlassian.net' , idOrKey : env. JIRA_TICKET
504
509
505
510
// Functional Reviewer - 10105
506
511
if (issue. data. fields. customfield_10105) {
507
512
println " Functional Reviewer: ${ issue.data.fields.customfield_10105.displayName} "
513
+ pullRequest. addLabel(' functional-review' )
508
514
} else {
509
515
println " No functional reviewer assigned."
510
516
}
@@ -518,9 +524,26 @@ pipeline {
518
524
def status = issue. data. fields. status
519
525
println " Issue Status: ${ status.name} (${ status.id} )"
520
526
521
- // For Issues with Functional reviewer and not validated
522
- if (issue. data. fields. customfield_10105 && status. id != " 10325" ) {
523
- unstable " Functional approval required."
527
+ // For Issues with Functional reviewer
528
+ if (issue. data. fields. customfield_10105) {
529
+ // Not validated
530
+ if (status. id != " 10325" ) {
531
+ // Ensure the PR is not already marked as changed requested
532
+ def lastFuncReviewStatus
533
+ for (review in pullRequest. reviews) {
534
+ if (review. user == " ironArt3mis" ) {
535
+ lastFuncReviewStatus = review. state
536
+ }
537
+ }
538
+ // PR already marked as review requested
539
+ if (lastFuncReviewStatus == " CHANGES_REQUESTED" ) {
540
+ echo " This PR is already marked as functional review required"
541
+ return
542
+ }
543
+ pullRequest. review(' REQUEST_CHANGES' , ' Functional review required' )
544
+ } else {
545
+ pullRequest. review(' APPROVE' )
546
+ }
524
547
}
525
548
}
526
549
}
0 commit comments