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

Unable to use SSHCheckoutTrait

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      branchSources {
         branchSource {
           source {
             github {
               ...
               traits {
                 sshCheckoutTrait {
                   credentialsId(CHECKOUT_SSH_CREDENTIALS_ID)            
                }
              }
             }
           }
         }
       }
      

      Leads to:

      Found multiple extensions which provide method sshCheckoutTrait with arguments [test_seed$_run_closure1$_closure2$_closure3$_closure4$_closure5$_closure6$_closure7@47c1791b]: [[com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait, org.jenkinsci.plugins.github_branch_source.SSHCheckoutTrait]]

       

        Attachments

          Issue Links

            Activity

            markus_heiden Markus Heiden created issue -
            stephenconnolly Stephen Connolly made changes -
            Field Original Value New Value
            Component/s configuration-as-code-plugin [ 23170 ]
            Hide
            deiga Timo Sand added a comment -

            I have the same issue, any knowledge of how to circumvent?

            Show
            deiga Timo Sand added a comment - I have the same issue, any knowledge of how to circumvent?
            Hide
            bitwiseman Liam Newman added a comment -

            The code above is in jobDSL, correct?

            Show
            bitwiseman Liam Newman added a comment - The code above is in jobDSL, correct?
            bitwiseman Liam Newman made changes -
            Description branchSources {
               branchSource {
                 source {
                   github {
                     ...
                     traits {
                     sshCheckoutTrait {
                         credentialsId(CHECKOUT_SSH_CREDENTIALS_ID)            
                       }
                    }
                   }
                 }
               }
            }  

            Leads to:

            Found multiple extensions which provide method sshCheckoutTrait with arguments [test_seed$_run_closure1$_closure2$_closure3$_closure4$_closure5$_closure6$_closure7@47c1791b]: [[com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait, org.jenkinsci.plugins.github_branch_source.SSHCheckoutTrait]]



             
            {{branchSources {
               branchSource {
                 source {
                   github {
                     ...
                     traits {
                     sshCheckoutTrait {
                         credentialsId(CHECKOUT_SSH_CREDENTIALS_ID)            
                       }
                    }
                   }
                 }
               }
            }  }}

            Leads to:

            Found multiple extensions which provide method sshCheckoutTrait with arguments [test_seed$_run_closure1$_closure2$_closure3$_closure4$_closure5$_closure6$_closure7@47c1791b]: [[com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait, org.jenkinsci.plugins.github_branch_source.SSHCheckoutTrait]]



             
            bitwiseman Liam Newman made changes -
            Description {{branchSources {
               branchSource {
                 source {
                   github {
                     ...
                     traits {
                     sshCheckoutTrait {
                         credentialsId(CHECKOUT_SSH_CREDENTIALS_ID)            
                       }
                    }
                   }
                 }
               }
            }  }}

            Leads to:

            Found multiple extensions which provide method sshCheckoutTrait with arguments [test_seed$_run_closure1$_closure2$_closure3$_closure4$_closure5$_closure6$_closure7@47c1791b]: [[com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait, org.jenkinsci.plugins.github_branch_source.SSHCheckoutTrait]]



             

            {code:groovy}
            branchSources {
               branchSource {
                 source {
                   github {
                     ...
                     traits {
                       sshCheckoutTrait {
                         credentialsId(CHECKOUT_SSH_CREDENTIALS_ID)            
                      }
                    }
                   }
                 }
               }
             }
            {code}


            Leads to:

            Found multiple extensions which provide method sshCheckoutTrait with arguments [test_seed$_run_closure1$_closure2$_closure3$_closure4$_closure5$_closure6$_closure7@47c1791b]: [[com.cloudbees.jenkins.plugins.bitbucket.SSHCheckoutTrait, org.jenkinsci.plugins.github_branch_source.SSHCheckoutTrait]]

             
            bitwiseman Liam Newman made changes -
            Remote Link This issue links to "github-branch-source PR #228 (Web Link)" [ 23119 ]
            Hide
            deiga Timo Sand added a comment -
            Show
            deiga Timo Sand added a comment - Liam Newman Yes
            Hide
            deiga Timo Sand added a comment - - edited

            Liam Newman The same issue with trying to use

            originPullRequestDiscoveryTrait
            

            }

            Show
            deiga Timo Sand added a comment - - edited Liam Newman The same issue with trying to use originPullRequestDiscoveryTrait }
            Hide
            deiga Timo Sand added a comment -

            I found a workaround, but it's Ugly as hell.

             organizationFolder('...') {
              organizations {
                ...
              }
              orphanedItemStrategy {
                ...
              }
              triggers {
                ...
              }
              configure {
                def traits = it / navigators / 'org.jenkinsci.plugins.github__branch__source.GitHubSCMNavigator' / traits
                traits << "org.jenkinsci.plugins.github__branch__source.SSHCheckoutTrait" {
                    credentialsId('...')
                }
                traits << 'org.jenkinsci.plugins.github_branch_source.OriginPullRequestDiscoveryTrait' {
                  strategyId 1
                }
              }
            }
            
            Show
            deiga Timo Sand added a comment - I found a workaround, but it's Ugly as hell. organizationFolder( '...' ) { organizations { ... } orphanedItemStrategy { ... } triggers { ... } configure { def traits = it / navigators / 'org.jenkinsci.plugins.github__branch__source.GitHubSCMNavigator' / traits traits << "org.jenkinsci.plugins.github__branch__source.SSHCheckoutTrait" { credentialsId( '...' ) } traits << 'org.jenkinsci.plugins.github_branch_source.OriginPullRequestDiscoveryTrait' { strategyId 1 } } }
            Hide
            bitwiseman Liam Newman added a comment -

            Timo Sand

            Yeah, JobDSL always has the configure block option. I agree it is ugly but in the short term it give you a work around (you could wrap that in method call and put it in a library to make it look cleaner).

            This sounds like something that would be better to fix/enhance in the JobDSL plugin. Maybe it could detect this from context? In the DSL,

            {sshCheckoutTrait}

            is a descendant of

            {github}

            , the package for which is

            {org.jenkinsci.plugins.github_branch_source}

            . If there a trait in the same package, it would seem reasonable to choose it instead of failing. Then all the branch source plugins would be fixed in one shot.

            Of course, I don't know enough about the JobDSL plugin to know if that would be difficult.

            Show
            bitwiseman Liam Newman added a comment - Timo Sand Yeah, JobDSL always has the configure block option. I agree it is ugly but in the short term it give you a work around (you could wrap that in method call and put it in a library to make it look cleaner). This sounds like something that would be better to fix/enhance in the JobDSL plugin. Maybe it could detect this from context? In the DSL, {sshCheckoutTrait} is a descendant of {github} , the package for which is {org.jenkinsci.plugins.github_branch_source} . If there a trait in the same package, it would seem reasonable to choose it instead of failing. Then all the branch source plugins would be fixed in one shot. Of course, I don't know enough about the JobDSL plugin to know if that would be difficult.
            bitwiseman Liam Newman made changes -
            Link This issue is related to JENKINS-45860 [ JENKINS-45860 ]
            bitwiseman Liam Newman made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            bitwiseman Liam Newman made changes -
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Fixed but Unreleased [ 10203 ]

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              markus_heiden Markus Heiden
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: