Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make plugin compatible with Job DSL #41

Merged
merged 3 commits into from
Nov 15, 2021
Merged

Make plugin compatible with Job DSL #41

merged 3 commits into from
Nov 15, 2021

Conversation

LEDfan
Copy link
Contributor

@LEDfan LEDfan commented Nov 9, 2021

Hi

First of all, a big thanks for picking up maintenance for this plugin again!

We are using this plugin with an initial root job using the job DSL. The current version of the plugin has two problems regarding DSL support:

  • it is impossible to configure the traits of giteaSCMNavigator
  • it is impossible to configure the giteaForkDiscovery trait

This PR adds full support for configuration via the Job DSL plugin.

Fixes:

@justusbunsi
Copy link
Member

Thanks for the PR. I'll test drive the changes in the next days.

@justusbunsi justusbunsi self-assigned this Nov 9, 2021
@justusbunsi
Copy link
Member

justusbunsi commented Nov 14, 2021

Hi @LEDfan. I've tested your changes and now it's really easy to configure traits. 👍
There would be just a few additional changes needed to have full Job DSL support - at least as far as it can be done within this plugin. It would also fix a few issues:

If you could add those changes to your PR as well, this would be awesome. Otherwise, I'll create an additional PR based on your changes. Please let me know how we proceed.

The changes would be...

  • Add @Symbol("gitea") to GiteaSCMNavigators DescriptorImpl
  • Fix upper/lower case typo in Symbol annotation of OriginPullRequestDiscoveryTrait
  • Add @Symbol("giteaSSHCheckout") to SSHCheckoutTraits DescriptorImpl
  • Add @Symbol("giteaTagDiscovery") to TagDiscoveryTraits DescriptorImpl
  • Add @Symbol("giteaWebhookRegistration") to WebhookRegistrationTraits DescriptorImpl

...to achieve a configuration like the following.

organizationFolder('gitea-org') {
  displayName('This is my Gitea organization')
  organizations {
    gitea {
      serverUrl("https://git.example.com")
      repoOwner("owner")
      credentialsId("gitea-token-credentials")

      traits {
        // Repository filter
        sourceWildcardFilter {
          includes("gitea-plugin")
          excludes("")
        }

        // Branch/Tag/PR filter
        headRegexFilter {
          regex("^(main|develop\\/.*|v\\d+|PR-.*)\$")
        }
        giteaExcludeArchivedRepositories {}
        giteaTagDiscovery {}
        giteaSSHCheckout {
          credentialsId('ssh-gitea')
        }
        giteaBranchDiscovery {
          strategyId(1)
        }
        giteaPullRequestDiscovery {
          strategyId(1)
        }
        giteaForkDiscovery {
          strategyId(1)
          trust {
            giteaTrustContributors {}
            // giteaTrustEveryone {}
            // giteaTrustNobody {}
          }
        }

        // Override webhook management
        giteaWebhookRegistration {
          mode('ITEM')
          // mode('DISABLED')
        }
      }
    }
  }
}

LEDfan and others added 2 commits November 15, 2021 11:43
Co-authored-by: Steven <61625851+justusbunsi@users.noreply.github.com>
@LEDfan
Copy link
Contributor Author

LEDfan commented Nov 15, 2021

Thanks @justusbunsi for the additional fixes, I integrated them into this PR.

Copy link
Member

@justusbunsi justusbunsi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for your addition to the plugin. 🤗

@justusbunsi
Copy link
Member

FYI, I've updated the PR description to match the actual changes.

@justusbunsi justusbunsi merged commit 1ca2a80 into jenkinsci:master Nov 15, 2021
@justusbunsi justusbunsi added this to the 1.4.0 milestone Nov 15, 2021
@LEDfan LEDfan deleted the bugfix/job_dsl branch November 16, 2021 07:16
@justusbunsi justusbunsi removed their assignment Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants