Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45504

Add @Symbol annotations to traits

    Details

    • Similar Issues:
    • Released As:
      git-plugin 4.0.0, bitbucket-branch-source-plugin 2.7.0, github-branch-source-plugin 2.6.0

      Description

      In order to make using traits easier, we need to add @Symbol annotations to the trait implementations.

        Attachments

          Issue Links

            Activity

            stephenconnolly Stephen Connolly created issue -
            Hide
            stephenconnolly Stephen Connolly added a comment -

            This issue is critically blocked by JENKINS-45503

            If there are two traits with the same @Symbol annotation then the annotation is ignored, thus until the generic discovery traits have been consolidated into SCM-API, we cannot add the @Symbol annotations that we would want to them.

            Ideally we would have

            // in SCM-API plugin
            @Symbol("discoverBranches")
            public class BranchDiscoveryTrait { ... }

            But without JENKINS-45503 we would be forced to implement this as

            // in Git plugin
            @Symbol("discoverGitBranches")
            public class BranchDiscoveryTrait { ... }
            
            // in GitHub Branch Source plugin
            @Symbol("discoverGitHubBranches")
            public class BranchDiscoveryTrait { ... }
            
            // in Bitbucket Branch Source plugin
            @Symbol("discoverBitbucketBranches")
            public class BranchDiscoveryTrait { ... }
            
            // etc

            Furthermore, if we added those annotations, then existing usage would be broken as soon as JENKINS-45503 was implemented unless SCM API had

            // in SCM-API plugin
            @Symbol({"discoverBranches","discoverGitBranches","discoverGitHubBranches","discoverBitbucketBranches"})
            public class BranchDiscoveryTrait { ... }

            Which is effectively encoding SCM specific names into the generic API

             

            Show
            stephenconnolly Stephen Connolly added a comment - This issue is critically blocked by JENKINS-45503 If there are two traits with the same @Symbol annotation then the annotation is ignored, thus until the generic discovery traits have been consolidated into SCM-API, we cannot add the @Symbol annotations that we would want to them. Ideally we would have // in SCM-API plugin @Symbol( "discoverBranches" ) public class BranchDiscoveryTrait { ... } But without JENKINS-45503 we would be forced to implement this as // in Git plugin @Symbol( "discoverGitBranches" ) public class BranchDiscoveryTrait { ... } // in GitHub Branch Source plugin @Symbol( "discoverGitHubBranches" ) public class BranchDiscoveryTrait { ... } // in Bitbucket Branch Source plugin @Symbol( "discoverBitbucketBranches" ) public class BranchDiscoveryTrait { ... } // etc Furthermore, if we added those annotations, then existing usage would be broken as soon as JENKINS-45503 was implemented unless SCM API had // in SCM-API plugin @Symbol({ "discoverBranches" , "discoverGitBranches" , "discoverGitHubBranches" , "discoverBitbucketBranches" }) public class BranchDiscoveryTrait { ... } Which is effectively encoding SCM specific names into the generic API  
            stephenconnolly Stephen Connolly made changes -
            Field Original Value New Value
            Link This issue is blocked by JENKINS-45503 [ JENKINS-45503 ]
            stephenconnolly Stephen Connolly made changes -
            Assignee Antonio Muñiz [ amuniz ]
            stephenconnolly Stephen Connolly made changes -
            Link This issue is blocked by JENKINS-44884 [ JENKINS-44884 ]
            jamesdumay James Dumay made changes -
            Labels cloudbees-internal-pipeline
            jamesdumay James Dumay made changes -
            Labels cloudbees-internal-pipeline cloudbees-internal-pipeline technical-debt
            Hide
            jamesdumay James Dumay added a comment -

            Note to self: Stephen Connolly mentioned this was an important future enhancement

            Show
            jamesdumay James Dumay added a comment - Note to self: Stephen Connolly mentioned this was an important future enhancement
            stephenconnolly Stephen Connolly made changes -
            Link This issue is duplicated by JENKINS-46202 [ JENKINS-46202 ]
            Hide
            nicodeceulaer Nico De Ceulaer added a comment -

             

            After updating our jenkins plugins, we are facing the problem that we cannot set the BranchDiscovery options on a multibranchPipelineJob through job-dsl.

            Googling around I found this issue that seems to explain why we cannot yet use the BranchDiscoveryTrait to fix this.

            Is there an existing workaround to get this behaviour (through a configure block ?)

            Show
            nicodeceulaer Nico De Ceulaer added a comment -   After updating our jenkins plugins, we are facing the problem that we cannot set the BranchDiscovery options on a multibranchPipelineJob through job-dsl. Googling around I found this issue that seems to explain why we cannot yet use the BranchDiscoveryTrait to fix this. Is there an existing workaround to get this behaviour (through a configure block ?)
            Hide
            stephenconnolly Stephen Connolly added a comment -

            I am not familiar enough with the job-dsl plugin to provide an answer Nico De Ceulaer

            Show
            stephenconnolly Stephen Connolly added a comment - I am not familiar enough with the job-dsl plugin to provide an answer Nico De Ceulaer
            Hide
            arty13 Art V added a comment -

            Nico De Ceulaer I don't have much experience with the configure block, but this is what I'm doing for my MultiBranch Job DSL configuration (it's a template I'm using):

            multibranchPipelineJob('${JOB_NAME}') {
                displayName('${JOB_NAME}')
                description('${JOB_DESCRIPTION}')
                orphanedItemStrategy {
                    discardOldItems {
                        numToKeep(7)
                    }
                }
                branchSources {
                    configure { node ->
                        node / sources(class: 'jenkins.branch.MultiBranchProject\$BranchSourceList') / data / 'jenkins.branch.BranchSource' / source(class: 'jenkins.plugins.git.GitSCMSource') {
                            id ''
                            remote '${JOB_GIT_URL}'
                            credentialsId '${GIT_CREDENTIALS_ID}'
                            includes '*'
                            excludes ''
                            ignoreOnPushNotifications 'false'
                            traits {
                                'jenkins.plugins.git.traits.BranchDiscoveryTrait'()
                                'jenkins.plugins.git.traits.WipeWorkspaceTrait'() {
                                    extension(class: 'hudson.plugins.git.extensions.impl.WipeWorkspace')
                                }
                                'jenkins.plugins.git.traits.PreBuildMergeTrait'() {
                                    extension(class: 'hudson.plugins.git.extensions.impl.PreBuildMerge') {
                                        options {
                                            mergeRemote 'origin'
                                            mergeTarget '${GIT_BRANCH}'
                                            mergeStrategy 'default'
                                            fastForwardMode 'FF'
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            

            I hope this helps you further.

            Show
            arty13 Art V added a comment - Nico De Ceulaer I don't have much experience with the configure block, but this is what I'm doing for my MultiBranch Job DSL configuration (it's a template I'm using): multibranchPipelineJob( '${JOB_NAME}' ) { displayName( '${JOB_NAME}' ) description( '${JOB_DESCRIPTION}' ) orphanedItemStrategy { discardOldItems { numToKeep(7) } } branchSources { configure { node -> node / sources(class: 'jenkins.branch.MultiBranchProject\$BranchSourceList' ) / data / 'jenkins.branch.BranchSource' / source(class: 'jenkins.plugins.git.GitSCMSource' ) { id '' remote '${JOB_GIT_URL}' credentialsId '${GIT_CREDENTIALS_ID}' includes '*' excludes '' ignoreOnPushNotifications ' false ' traits { 'jenkins.plugins.git.traits.BranchDiscoveryTrait' () 'jenkins.plugins.git.traits.WipeWorkspaceTrait' () { extension(class: 'hudson.plugins.git.extensions.impl.WipeWorkspace' ) } 'jenkins.plugins.git.traits.PreBuildMergeTrait' () { extension(class: 'hudson.plugins.git.extensions.impl.PreBuildMerge' ) { options { mergeRemote 'origin' mergeTarget '${GIT_BRANCH}' mergeStrategy ' default ' fastForwardMode 'FF' } } } } } } } } I hope this helps you further.
            stephenconnolly Stephen Connolly made changes -
            Link This issue is duplicated by JENKINS-45860 [ JENKINS-45860 ]
            Hide
            stephenconnolly Stephen Connolly added a comment -

            https://issues.jenkins-ci.org/browse/JENKINS-45860 may have some hints at how to workaround using Job DSL

            Show
            stephenconnolly Stephen Connolly added a comment - https://issues.jenkins-ci.org/browse/JENKINS-45860 may have some hints at how to workaround using Job DSL
            stephenconnolly Stephen Connolly made changes -
            Link This issue is duplicated by JENKINS-45688 [ JENKINS-45688 ]
            Show
            sag47 Sam Gleske added a comment - I have proposed for the git-plugin https://github.com/jenkinsci/git-plugin/pull/595 I am successfully using the following Job DSL. https://github.com/gimp-ci/jenkins-dsl/blob/2c53863eca8d689f23bd8554a3cd47831bfa7606/jobs/gimp_multibranch_pipelines.groovy#L27-L29
            Hide
            ccaraivan Costin Caraivan added a comment -

            Could this be bumped in priority? These traits are used downstream by the job DSL plugin and their lack forces users to restot to the configure block in the job DSL configurations, which is an unsafe hack, basically.

            Show
            ccaraivan Costin Caraivan added a comment - Could this be bumped in priority? These traits are used downstream by the job DSL plugin and their lack forces users to restot to the configure block in the job DSL configurations, which is an unsafe hack, basically.
            daspilker Daniel Spilker made changes -
            Link This issue is duplicated by JENKINS-54877 [ JENKINS-54877 ]
            pleibiger Peter Leibiger made changes -
            Link This issue is related to JENKINS-58829 [ JENKINS-58829 ]
            markewaite Mark Waite made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            markewaite Mark Waite made changes -
            Status Resolved [ 5 ] Fixed but Unreleased [ 10203 ]
            Hide
            markewaite Mark Waite added a comment -

            Included in git plugin 4.0.0 released Nov 2, 2019

            Show
            markewaite Mark Waite added a comment - Included in git plugin 4.0.0 released Nov 2, 2019
            markewaite Mark Waite made changes -
            Status Fixed but Unreleased [ 10203 ] Closed [ 6 ]
            Hide
            sag47 Sam Gleske added a comment -

            Thanks for your work Mark Waite

            Show
            sag47 Sam Gleske added a comment - Thanks for your work Mark Waite
            renescheibe René Scheibe made changes -
            Remote Link This issue links to "github-branch-source-plugin pr183 (Web Link)" [ 23946 ]
            renescheibe René Scheibe made changes -
            Remote Link This issue links to "github-branch-source-plugin pr183 (Web Link)" [ 23946 ]
            renescheibe René Scheibe made changes -
            Remote Link This issue links to "github-branch-source-plugin pr#183 (Web Link)" [ 23947 ]
            renescheibe René Scheibe made changes -
            Remote Link This issue links to "git-plugin pr#595 (Web Link)" [ 23948 ]
            renescheibe René Scheibe made changes -
            Remote Link This issue links to "github-branch-source-plugin pr#258 (Web Link)" [ 23950 ]
            renescheibe René Scheibe made changes -
            Remote Link This issue links to "bitbucket-branch-source-plugin pr#257 (Web Link)" [ 23951 ]
            Hide
            renescheibe René Scheibe added a comment -

            This is not fixed yet, therefore I reopen it.

            There are still the bitbucket-branch-source-plugin and github-branch-source-plugin to be fixed. I opened pull requests for them:

            Show
            renescheibe René Scheibe added a comment - This is not fixed yet, therefore I reopen it. There are still the bitbucket-branch-source-plugin and github-branch-source-plugin to be fixed. I opened pull requests for them: https://github.com/jenkinsci/bitbucket-branch-source-plugin/pull/257 https://github.com/jenkinsci/github-branch-source-plugin/pull/258
            renescheibe René Scheibe made changes -
            Resolution Fixed [ 1 ]
            Status Closed [ 6 ] Reopened [ 4 ]
            markewaite Mark Waite made changes -
            Status Reopened [ 4 ] Open [ 1 ]
            Hide
            markewaite Mark Waite added a comment -

            René Scheibe has this now been resolved since the two pull requests you listed have been merged?

            Show
            markewaite Mark Waite added a comment - René Scheibe has this now been resolved since the two pull requests you listed have been merged?
            Hide
            renescheibe René Scheibe added a comment -

            The former status was correct (fixed but unreleased). I am still waiting for releases of the two plugins. I would then add the version numbers here for reference and close the ticket afterwards.

            Show
            renescheibe René Scheibe added a comment - The former status was correct (fixed but unreleased). I am still waiting for releases of the two plugins. I would then add the version numbers here for reference and close the ticket afterwards.
            renescheibe René Scheibe made changes -
            Released As git-plugin 4.0.0, bitbucket-branch-source-plugin TODO, github-branch-source-plugin TODO
            agabrys Adam Gabryś made changes -
            Link This issue relates to JENKINS-60874 [ JENKINS-60874 ]
            agabrys Adam Gabryś made changes -
            Link This issue relates to JENKINS-60874 [ JENKINS-60874 ]
            agabrys Adam Gabryś made changes -
            Link This issue is related to JENKINS-60874 [ JENKINS-60874 ]
            renescheibe René Scheibe made changes -
            Released As git-plugin 4.0.0, bitbucket-branch-source-plugin TODO, github-branch-source-plugin TODO git-plugin 4.0.0, bitbucket-branch-source-plugin 2.7.0, github-branch-source-plugin TODO
            renescheibe René Scheibe made changes -
            Released As git-plugin 4.0.0, bitbucket-branch-source-plugin 2.7.0, github-branch-source-plugin TODO git-plugin 4.0.0, bitbucket-branch-source-plugin 2.7.0, github-branch-source-plugin 2.6.0
            Hide
            renescheibe René Scheibe added a comment -

            Now a release for each of the 3 plugins has been performed that contains the relevant changes. Thanks everybody.

            Show
            renescheibe René Scheibe added a comment - Now a release for each of the 3 plugins has been performed that contains the relevant changes. Thanks everybody.
            renescheibe René Scheibe made changes -
            Status Open [ 1 ] Fixed but Unreleased [ 10203 ]
            Resolution Fixed [ 1 ]
            renescheibe René Scheibe made changes -
            Status Fixed but Unreleased [ 10203 ] Resolved [ 5 ]
            renescheibe René Scheibe made changes -
            Status Resolved [ 5 ] Closed [ 6 ]
            bitwiseman Liam Newman made changes -
            Link This issue is duplicated by JENKINS-57942 [ JENKINS-57942 ]
            Hide
            codiophile Erik Blomqvist added a comment -

            I'm really struggling to find documentation on how to use these traits with Job DSL. Can anyone point me in the right direction or is the documentation simply missing? Having to chose a number for the strategy id is anything but self-explanatory. I want to know what the available options are and what they do.

            Show
            codiophile Erik Blomqvist added a comment - I'm really struggling to find documentation on how to use these traits with Job DSL. Can anyone point me in the right direction or is the documentation simply missing? Having to chose a number for the strategy id is anything but self-explanatory. I want to know what the available options are and what they do.
            stephenconnolly Stephen Connolly made changes -
            Hide
            stephenconnolly Stephen Connolly added a comment -

            Erik Blomqvist I recommend using the pipeline snippet generator with the `resolveScm` step as that lets you see the effects on an SCMSource instance.

            See attached video:

            Show
            stephenconnolly Stephen Connolly added a comment - Erik Blomqvist I recommend using the pipeline snippet generator with the `resolveScm` step as that lets you see the effects on an SCMSource instance. See attached video:

              People

              • Assignee:
                Unassigned
                Reporter:
                stephenconnolly Stephen Connolly
              • Votes:
                24 Vote for this issue
                Watchers:
                35 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: