question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set branchDiscoveryTrait on globalLibraries

See original GitHub issue

Never report security issues in github, follow the instruction from Jenkins Security to report it on Jenkins Jira

Please make sure to provide following information in your issue description

  • Jenkins version: 2.138.1
  • Plugin version: 1.3
  • OS: CentOS 7.5

Context

I’m so close to being able to use this plugin in production for our team. The last piece missing is the branchDiscoveryTrait I’m trying to set on a global library.

Code snippet

jenkins:
  [...]
unclassified:
  [...]
    globalLibraries:
    libraries:
      - name: <our repo name>
        defaultVersion: master
        implicit: true
        includeInChangeSets: true
        retriever:
          modernSCM:
            scm:
              github:
                apiUri: <our URL>
                credentialsId: <our creds>
                repoOwner: <our owner>
                repository: <our repo>
                traits:
                  - branchDiscoveryTrait # <--- issue right here
                  - originPullRequestDiscoveryTrait
                  - forkPullRequestDiscoveryTrait

Logs

Here are the logs when starting Jenkins:

INFO: Setting org.jenkinsci.plugins.github_branch_source.GitHubSCMSource{id='null'}.traits = [jenkins.plugins.git.traits.BranchDiscoveryTrait@3fb360b2, org.jenkinsci.plugins.github_branch_source.OriginPullRequestDiscoveryTrait@6b2b17b9, org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait@5938a4bb]

Result

originPullRequestDiscoveryTrait and forkPullRequestDiscoveryTrait are configured correctly, but branchDiscoveryTrait never appears. Note that applying the configuration does not result in an error/stack trace.

image

Any help would be fantastic. Excited to have a modern, ____-as-code approach to managing Jenkins. Thank you!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mitchnielsencommented, Dec 6, 2018

When I try to export existing configuration after selecting the option with the UI, it still fails. Here’s the config in jenkins.yml that I use:

...
traits:
- branchDiscoveryTrait:
    strategyId: 1
- originPullRequestDiscoveryTrait:
    strategyId: 1
- forkPullRequestDiscoveryTrait:
    strategyId: 1

And I get this error when loading the config:

io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration elements for type class jenkins.plugins.git.traits.BranchDiscoveryTrait : strategyId.
Available attributes : 
	at io.jenkins.plugins.casc.BaseConfigurator.handleUnknown(BaseConfigurator.java:363)
	at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:352)
	at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:262)
	at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.configure(DataBoundConfigurator.java:81)
0reactions
mitchnielsencommented, Feb 11, 2019

That’s great, thanks for following up and letting us know!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found