While trying to bootstrap a Jenkins instance through configuration as code and seed jobs we tried to do something like is showcased here https://github.com/jenkinsci/configuration-as-code-plugin/blob/configuration-as-code-1.46/demos/jobs/bitbucket.yaml

       

      Here's is what we tried:

      organizationFolder('Gitea demo Folder') {
          description("Track demo Gitea repositories and their events")
          displayName('Gitea demo')
          organizations { 
              gitea {
                  serverUrl("https://localhost:3000")
                  repoOwner("demo")
                  credentialsId("2d7e92d6-072d-407a-8389-976e7222fd09")
              }
          }    
      }
      
      

      and the error message:

       

      Started by user jenkins
      Running as SYSTEM
      Building in workspace /var/jenkins_home/workspace/gitea-seed-job
      Processing provided DSL script
      ERROR: (script, line 6) No signature of method: javaposse.jobdsl.dsl.helpers.workflow.ScmNavigatorsContext.gitea() is applicable for argument types: (script$_run_closure1$_closure2$_closure3) values: [script$_run_closure1$_closure2$_closure3@2642e6e7]
      Possible solutions: grep(), with(groovy.lang.Closure), grep(java.lang.Object), getAt(java.lang.String), wait(), find()
      Finished: FAILURE
      

      I can't for the life of me figure out where those methods should exist, but if someone can point me in the right direction we can implement a pull request.

          [JENKINS-64580] Unable to add Gitea Org through Job DSL

          Steven added a comment -

          Actually, it's possible to configure Gitea organizations through JobDSL. But I admit that it is neither intuitive nor easy to maintain. It's quite a hack. Would look like the following. Maybe it helps for your environment as long as the plugin doesn't actually support `configuration-as-code`.

          organizationFolder('my-organization') {
            displayName('Custom Display name')
            organizations {
              orphanedItemStrategy {
                discardOldItems {
                  daysToKeep(-1)
                  numToKeep(-1)
                }
              }
              configure { node ->
                def navigators = node / navigators
                navigators << "org.jenkinsci.plugin.gitea.GiteaSCMNavigator" {
                  serverUrl("https://example.com")
                  repoOwner("fake-owner")
                  credentialsId("fake-credentials")
                }
          
                def templates = node / 'properties' / 'jenkins.branch.OrganizationChildTriggersProperty' / templates
                templates << 'com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger' {
                  spec("H H/4 * * *")
                  interval(86400000)
                }
          
                def traits = navigators / 'org.jenkinsci.plugin.gitea.GiteaSCMNavigator' / traits
                traits << "org.jenkinsci.plugin.gitea.OriginPullRequestDiscoveryTrait" {
                  strategyId("1")
                }
                traits << "org.jenkinsci.plugin.gitea.BranchDiscoveryTrait" {
                  strategyId("1")
                }
                traits << "org.jenkinsci.plugin.gitea.TagDiscoveryTrait" {}
                traits << "org.jenkinsci.plugin.gitea.ExcludeArchivedRepositoriesTrait" {}
                traits << "org.jenkinsci.plugin.gitea.SSHCheckoutTrait" {
                  credentialsId('gitea-ssh')
                }
          
                node / triggers / "com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger" {
                  spec("H H/4 * * *")
                  interval(86400000)
                }
          
                def strategies = node / 'buildStrategies'
                strategies << 'jenkins.branch.buildstrategies.basic.BranchBuildStrategyImpl' {}
                strategies << 'jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl' {
                  ignoreTargetOnlyChanges(true)
                  ignoreUntrustedChanges(false)
                }
                strategies << 'jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl' {
                  atLeastMillis(-1)
                  atMostMillis(172800000)
                }
              }
            }
          }
          

          Steven added a comment - Actually, it's possible to configure Gitea organizations through JobDSL. But I admit that it is neither intuitive nor easy to maintain. It's quite a hack. Would look like the following. Maybe it helps for your environment as long as the plugin doesn't actually support `configuration-as-code`. organizationFolder( 'my-organization' ) { displayName( 'Custom Display name' ) organizations { orphanedItemStrategy { discardOldItems { daysToKeep(-1) numToKeep(-1) } } configure { node -> def navigators = node / navigators navigators << "org.jenkinsci.plugin.gitea.GiteaSCMNavigator" { serverUrl( "https: //example.com" ) repoOwner( "fake-owner" ) credentialsId( "fake-credentials" ) } def templates = node / 'properties' / 'jenkins.branch.OrganizationChildTriggersProperty' / templates templates << 'com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger' { spec( "H H/4 * * *" ) interval(86400000) } def traits = navigators / 'org.jenkinsci.plugin.gitea.GiteaSCMNavigator' / traits traits << "org.jenkinsci.plugin.gitea.OriginPullRequestDiscoveryTrait" { strategyId( "1" ) } traits << "org.jenkinsci.plugin.gitea.BranchDiscoveryTrait" { strategyId( "1" ) } traits << "org.jenkinsci.plugin.gitea.TagDiscoveryTrait" {} traits << "org.jenkinsci.plugin.gitea.ExcludeArchivedRepositoriesTrait" {} traits << "org.jenkinsci.plugin.gitea.SSHCheckoutTrait" { credentialsId( 'gitea-ssh' ) } node / triggers / "com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger" { spec( "H H/4 * * *" ) interval(86400000) } def strategies = node / 'buildStrategies' strategies << 'jenkins.branch.buildstrategies.basic.BranchBuildStrategyImpl' {} strategies << 'jenkins.branch.buildstrategies.basic.ChangeRequestBuildStrategyImpl' { ignoreTargetOnlyChanges( true ) ignoreUntrustedChanges( false ) } strategies << 'jenkins.branch.buildstrategies.basic.TagBuildStrategyImpl' { atLeastMillis(-1) atMostMillis(172800000) } } } }

            stephenc Stephen Connolly
            jam01 Jose
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: