Scenario:
When using Swarm as a branch source you see a list of open reviews. It is possible for end users in Swarm to commit pre-commit reviews outside of swarm which leaves the review open. Over time these build up and no one tidies them up.Â
Request:
It would be good if we could hide jobs for open pre-commit reviews in Swarm that have commits attached.
Workaround:
Project managers should review open requests in Swarm frequently and close open reviews that are no longer required.
Implementation notes:
An open pre-commit review can have a commit attached when the users submits the review outside Swarm. For example:
http://SWARM/api/v9/reviews/2636?fields=projects%2Cchanges%2Ccommits%2Cauthor%2Cstate { Â "review": { Â Â "author": "super", Â Â "changes": [ Â Â Â 2635, Â Â Â 2637, Â Â Â 2641 Â Â ], Â Â "commits": [ Â Â Â 2641 Â Â ], Â Â "projects": { Â Â Â "project1": [ Â Â Â Â "main" Â Â Â ] Â Â }, Â Â "state": "needsReview" Â } }
Note that the 'commits' are different to the 'changes'.
Â
An open post-commit review will always have one or more commits attached. For example:
Â
http://SWARM/api/v9/reviews/2640?fields=projects%2Cchanges%2Ccommits%2Cauthor%2Cstate { Â "review": { Â Â "author": "super", Â Â "changes": [ Â Â Â 2639 Â Â ], Â Â "commits": [ Â Â Â 2639 Â Â ], Â Â "projects": { Â Â Â "project1": [ Â Â Â Â "main" Â Â Â ] Â Â }, Â Â "state": "needsReview" Â } }
and:
Â
Â
http://SWARM/api/v9/reviews/2640?fields=projects%2Cchanges%2Ccommits%2Cauthor%2Cstate { Â "review": { Â Â "author": "super", Â Â "changes": [ Â Â Â 2639, Â Â Â 2642 Â Â ], Â Â "commits": [ Â Â Â 2639, Â Â Â 2642 Â Â ], Â Â "projects": { Â Â Â "project1": [ Â Â Â Â "main" Â Â Â ] Â Â }, Â Â "state": "needsReview" Â } }
Note that these commits mirror the 'chenges' field.
Â
Suggest that an tick box is added per job that changes the behavior (we cant break existing behavior). Example:
 A tickbox on the job that is called 'Hide open committed pre-commit review' which hides jobs that have something in the 'commits' list where the 'commits' list is not equal to the 'changes' list seen via the SWARM 'reviews' REST endpoint.Â
Â
Testing:
(1) Create a Swarm project with one branch.
(2) Submit a simple Jenkinsfile to the top of that branch. For example:
pipeline {
  agent any
  stages {
    stage('Hello') {
      steps {
        echo 'Hello World'
      }
    }
  }
}
(3) Create a multibranch pipeline project with Swarm as the branch source and use the project from step 1.
(4) Create a reviewing using the P4 command line:
echo test > test1.txt
p4 add test1.txt
p4 shelve # Enter the changelist description "Creating a review #review"
(5) Click on scan multibranch pipeline in the Jenkins job. The Swarm job should appear.
(6) Submit the shelve from step (4).
p4 shelve -d SHELVE_NUMBER p4 submit -c SHELVE_NUMBER
(7) Click on scan multibranch pipeline in the Jenkins job. The Swarm job should now disappear. Current behavior is that the review remains until a user manually approves the review.
Â
Â
Â