jenkinsci / configuration-as-code-plugin

Jenkins Configuration as Code Plugin
https://plugins.jenkins.io/configuration-as-code
MIT License
2.69k stars 719 forks source link

Gitlab/Github/Bitbucket multibranchPipelineJob Support #2259

Closed ksuhdilla closed 1 year ago

ksuhdilla commented 1 year ago

What feature do you want to see added?

Hello, as a user of Jenkins' CasC, it would be great if we could add support to the multibranchPipeline branchSources for Gitlab, and Bitbucket. This would allow a tighter integration with these platforms and allow the initial seed jobs to come up as multi-branch pipelines with very little massaging.

jobs:
  - script: >
      organizationFolder('official-products')
      {
        description("This is where all the fun is")
        displayName('official-team-name')
        organizations
        {
          gitlab
          {
            serverName("gitserver")
            projectOwner("parent")
            credentialsId("jenkins-key")
          }
        }
      }
  - script: >
      multibranchPipelineJob('old-immovable-legacy-project') {
        branchSources {
          gitlab {
            serverName("gitserver")
            projectOwner("parent")
            projectName("legacyprojectl")
            credentialsId("jenkins-key")
          }
        }
      }

I will be more than happy to contribute to this fix if needed - but this will be my first time contributing to any Jenkins project - I'm also unaware if there was ever a philosophical reason to not add these other platforms since GitHub is supported. Is it more of a legacy feature and CasC is trying to embrace organizational folders? I love to learn, I just need a little bit of guidance

Upstream changes

No response

timja commented 1 year ago

Configuration as code plugin just delegates to other plugins for almost all behaviour.

https://github.com/jenkinsci/job-dsl-plugin/ is what provides the functionality for jobs. Best to take a look over there and at their issue tracker.

ksuhdilla commented 1 year ago

Hi @timja,

Yes, I have the job-dsl-plugin installed and I have several seed jobs that come up but it's the multibranchPipelineJob -> branchSources -> gitlab that is causing exceptions. When I look at the definition for https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob I see it does not support GitLab only GitHub/Git

The desire would be to have one instance of jenkins become portable and have this portable jenkins identical to what is officially used for this organization. When I execute casc I see the following stacktrace:

groovy.lang.MissingMethodException: No signature of method: javaposse.jobdsl.dsl.helpers.workflow.BranchSourcesContext.gitlab() is applicable for argument types: (script$_run_closure1$_closure2$_closure3) values: [script$_run_closure1$_closure2$_closure3@4289df06]

Am I misunderstanding?

timja commented 1 year ago

Please discuss on the jobdsl or gitlab issue trackers or on the community forum or the chat channels.

This isn't anything to do with the configuration as code plugin