P4 plugin - Multibranch PRs and Branches

48 views
Skip to first unread message

pallen

unread,
Jun 12, 2017, 7:22:44 AM6/12/17
to Jenkins Developers
Hi Guys,

I'm looking to update the merge/review functionality of the P4 plugin and had a few questions:

(1) How does Multibranch determine a PR or Branch is closed, so that it is displayed with strikethrough the text?  Is this part of the retrieve/observe mechanism in the scm-api plugin?

For example, PR-46 in the image below:


(2) The two tabs, shown above 'Branches' and 'Pull Requests' are these just filters set in Multibranch or defined programmatically as part of the github plugin?



Kind regards,
Paul

Stephen Connolly

unread,
Jun 12, 2017, 8:12:09 AM6/12/17
to jenkin...@googlegroups.com
On 12 June 2017 at 12:22, pallen <pal...@perforce.com> wrote:
Hi Guys,

I'm looking to update the merge/review functionality of the P4 plugin and had a few questions:

this week I am pushing the traits changes... you may want to adopt those, plan accordingly.
 

(1) How does Multibranch determine a PR or Branch is closed, so that it is displayed with strikethrough the text?  Is this part of the retrieve/observe mechanism in the scm-api plugin?

when the scm-api no longer returns the branch or pull request, then it is considered an orphaned branch.

orphaned branch jobs cannot be deleted immediately because the orphaned branch strategy that the user configures may not be able to determine which branches are eligible for deletion until it has a complete list of orphaned branches (which means we need to wait for a full scan)
 

For example, PR-46 in the image below:


(2) The two tabs, shown above 'Branches' and 'Pull Requests' are these just filters set in Multibranch or defined programmatically as part of the github plugin?

Each SCMHeadCategory that your plugin enumerates will be given its own tab. You can control the names of these.

Please read:


It is the documentation for anyone wanting to implement SCM API support in an SCM plugin
 


Kind regards,
Paul

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f0ef7486-446f-4051-8a9f-d5423a739571%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stephen Connolly

unread,
Jun 12, 2017, 8:12:50 AM6/12/17
to jenkin...@googlegroups.com
On 12 June 2017 at 13:11, Stephen Connolly <stephen.al...@gmail.com> wrote:


On 12 June 2017 at 12:22, pallen <pal...@perforce.com> wrote:
Hi Guys,

I'm looking to update the merge/review functionality of the P4 plugin and had a few questions:

this week I am pushing the traits changes... you may want to adopt those, plan accordingly.
 

(1) How does Multibranch determine a PR or Branch is closed, so that it is displayed with strikethrough the text?  Is this part of the retrieve/observe mechanism in the scm-api plugin?

when the scm-api no longer returns the branch or pull request, then it is considered an orphaned branch.

orphaned branch jobs cannot be deleted immediately because the orphaned branch strategy that the user configures may not be able to determine which branches are eligible for deletion until it has a complete list of orphaned branches (which means we need to wait for a full scan)
 

For example, PR-46 in the image below:


(2) The two tabs, shown above 'Branches' and 'Pull Requests' are these just filters set in Multibranch or defined programmatically as part of the github plugin?

Each SCMHeadCategory that your plugin enumerates will be given its own tab. You can control the names of these.

Please read:


It is the documentation for anyone wanting to implement SCM API support in an SCM plugin

Yes I have to update these docs for traits, but the delta should not be too bad

Stephen Connolly

unread,
Jun 12, 2017, 8:18:26 AM6/12/17
to jenkin...@googlegroups.com
On 12 June 2017 at 13:11, Stephen Connolly <stephen.al...@gmail.com> wrote:


On 12 June 2017 at 12:22, pallen <pal...@perforce.com> wrote:
Hi Guys,

I'm looking to update the merge/review functionality of the P4 plugin and had a few questions:

this week I am pushing the traits changes... you may want to adopt those, plan accordingly.
 

(1) How does Multibranch determine a PR or Branch is closed, so that it is displayed with strikethrough the text?  Is this part of the retrieve/observe mechanism in the scm-api plugin?

when the scm-api no longer returns the branch or pull request, then it is considered an orphaned branch.

orphaned branch jobs cannot be deleted immediately because the orphaned branch strategy that the user configures may not be able to determine which branches are eligible for deletion until it has a complete list of orphaned branches (which means we need to wait for a full scan)
 

For example, PR-46 in the image below:


(2) The two tabs, shown above 'Branches' and 'Pull Requests' are these just filters set in Multibranch or defined programmatically as part of the github plugin?

Each SCMHeadCategory that your plugin enumerates will be given its own tab. You can control the names of these.

Please read:


It is the documentation for anyone wanting to implement SCM API support in an SCM plugin

See if you can spot the place where I designed the API so that perforce can have it's tab called "Change Reviews" instead of "Pull Requests" ;-) 

Paul Allen

unread,
Jun 12, 2017, 9:45:30 AM6/12/17
to jenkin...@googlegroups.com
Hi Stephen,

(1) Thank you - so if I understand correctly, if retrieve no longer finds it observer is not called and it appears crossed out.

(2) Should I implement my own SCMHeadCategory to for my P4Head (extends SCMHead)? If I need different types (e.g. 'Branches', 'Pull Requests') I need new implementations of SCMHead and a corresponding SCMHeadCategory?

I'm using scm-api 2.0.2 and a Jenkins version of 1.642.3

Kind regards,
Paul


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CA%2BnPnMxrJEF64Xt5%3DFReOGybeyb0OzFW-GG5ZSQGXB9qimpz5A%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--------------------------------------------------------------------------------
Perforce Software UK Ltd is registered in England and Wales as company no.
3816019 at the following address: West Forest Gate,
Wellington Road, Wokingham,
RG40 2AT, UK
--------------------------------------------------------------------------------

Paul Allen

unread,
Jun 12, 2017, 9:53:28 AM6/12/17
to jenkin...@googlegroups.com
BTW I have not implemented SCMNavigator, is this required?

Stephen Connolly

unread,
Jun 12, 2017, 10:03:33 AM6/12/17
to jenkin...@googlegroups.com
On 12 June 2017 at 14:45, Paul Allen <pal...@perforce.com> wrote:
Hi Stephen,

(1) Thank you - so if I understand correctly, if retrieve no longer finds it observer is not called and it appears crossed out.

Correct
 

(2) Should I implement my own SCMHeadCategory to for my P4Head (extends SCMHead)? If I need different types (e.g. 'Branches', 'Pull Requests') I need new implementations of SCMHead and a corresponding SCMHeadCategory?


Hint: I believe the docs are very explicit on that subject. There is, to my mind, an unambiguous answer directly to your question (somewhere in the middle third of the docs)

I really am looking for people to find faults in the docs. If I keep giving people answers then I become the scalability issue. I would much rather that people can solve the problems by reading documentation. That means that my efforts deliver a multiple rather than everything being rate limited by my time and availability. By using the docs and suggesting improvements we make the whole community better.

;-)


I'm using scm-api 2.0.2 and a Jenkins version of 1.642.3

Kind regards,
Paul


On 12 Jun 2017, at 13:18, Stephen Connolly <stephen.alan.connolly@gmail.com> wrote:

--------------------------------------------------------------------------------
Perforce Software UK Ltd is registered in England and Wales as company no.
3816019 at the following address: West Forest Gate,
Wellington Road, Wokingham,
RG40 2AT, UK
--------------------------------------------------------------------------------

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.

Paul Allen

unread,
Jun 12, 2017, 10:58:41 AM6/12/17
to jenkin...@googlegroups.com

(2) Should I implement my own SCMHeadCategory to for my P4Head (extends SCMHead)? If I need different types (e.g. 'Branches', 'Pull Requests') I need new implementations of SCMHead and a corresponding SCMHeadCategory?


Hint: I believe the docs are very explicit on that subject. There is, to my mind, an unambiguous answer directly to your question (somewhere in the middle third of the docs)

Each jenkins.scm.api.SCMSourceDescriptor should provide the concrete instances of the jenkins.scm.api.SCMHeadCategory that are potentially generated by their jenkins.scm.api.SCMSource instances. Then each jenkins.scm.api.SCMSource instance can filter down that list to the actual categories that may be returned by that specific source. For example, a GitHub source may return "Branches", "Pull Requests" and "Tags" but the user may have configured their specific source for a specific project to only build "Branches" and "Tags".


I really am looking for people to find faults in the docs. If I keep giving people answers then I become the scalability issue. I would much rather that people can solve the problems by reading documentation. That means that my efforts deliver a multiple rather than everything being rate limited by my time and availability. By using the docs and suggesting improvements we make the whole community better.

;-)

Before I posted I had read the implementation doc, it covers a lot and not easy to dip into.  A few more sections and headers would help out ;-)  It would be nice to add anchor markers when sending out links in emails.

The example for Accurev shows you reusing UncategorisedSCMSourceCategory and calling it 'Streams' and using TagSCMHeadCategory and calling it 'Snapshots'.


       protected SCMHeadCategory[] createCategories() {
            return new SCMSourceCategory[]{
                new UncategorizedSCMSourceCategory(
                    new NonLocalizable("Streams")
                    // Better: Messages._AccurevSCMSource_StreamHeadCategory()
                ),
                new TagSCMHeadCategory(
                    new NonLocalizable("Snapshots")
                    // Better: Messages._AccurevSCMSource_SnapshotHeadCategory()
                )
            };
        }

The Descriptor adds these to the createCategories, but doesn't say how they get referenced.

BTW: UncategorizedSCMHeadCategory.INSTANCE should be DEFAULT

 protected SCMHeadCategory[] createCategories() {
            return new SCMHeadCategory[]{
                    UncategorizedSCMHeadCategory.INSTANCE,
                    ChangeRequestSCMHeadCategory.DEFAULT,
                    TagSCMHeadCategory.DEFAULT
            };

The Tip's box starting 'Both tags and regular branches can normally use...' (somewhere near the middle) is very hard to read as the text is cropped and you have to scroll sideways to read it (viewed in Chrome on OS X).

The example inside this tip box using 'implements ChangeRequestSCMHead2' hints that Change requests are managed differently; and this has confused me further?

So does each SCMSource have to override createCategories() in its own implementation of SCMSourceDescriptor?  but how does it link to the SCMRevsion when retrieve adds them to observe?

I'm clearly missing something and I can't find a working example?  Is this implemented anywhere for real? I can't see it in the git, github and accurev plugins.

Sorry if I don't get it, I only posted as I could not get my head around the docs.

Stephen Connolly

unread,
Jun 12, 2017, 11:19:43 AM6/12/17
to jenkin...@googlegroups.com
I'm kind of a bit zonked... having finally got to the stage where I can create the PR for switching Bitbucket to traits: https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/53

I need to now repeat the same for GitHub (I have most of the changes ready, just need to flesh out javadoc comments, add help files, and write some more test cases)

If you have concrete suggestions for improving the doc, please please file PRs

Your other questions will probably get an answer tomorrow after I finish decompressing and have girded my loins sufficiently to start polishing off the GitHub Branch source changes now that I am happy that traits work well across the SCM systems that need it most.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.

Paul Allen

unread,
Jun 12, 2017, 11:29:29 AM6/12/17
to jenkin...@googlegroups.com
Sorry if my timing is off.  I'll take a look over the BitBucket code this week and ping you later on if I can't figure it out.

Thanks for the help on (1) and hopefully I'll solve (2) soon.


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CA%2BnPnMy41PauhcVgmPeSaKr1K%3DP1kLigqru_CJxy8kVuXxrnjA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages