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

Job DSL runs brefore Gitea servers are loaded

    Details

    • Similar Issues:

      Description

      When using Configuration as Code to setup Jenkins with a Gitea server and a mult-branch pipeline, the Job DSL will be run before the Gitea servers are added and it will error that it cannot find the Gitea server when running the first scan, this requires you to manually scan on startup.

      Relevant jenkins.yaml:

      unclassified:
        giteaServers:
          servers:
            - serverUrl: "SERVER_URL"
              displayName: "Gitea Server"
              credentialsId: "gitea_login"
      
      jobs:
        - script: >
            multibranchPipelineJob('JOB') {
              branchSources {
                branchSource {
                  source {
                    giteaSCMSource {
                      id('12312313')
                      credentialsId('gitea_login')
                      repoOwner('USER')
                      repository('REPO')
                      serverUrl("SERVER_URL")
                      traits {
                        cloneOptionTrait {
                          extension {
                            noTags(false)
                            shallow(false)
                            reference("")
                            timeout(10)
                          }
                        }
                        wipeWorkspaceTrait()
                      }
                    }
                  }
                }
              }
              configure { node ->
                def traits = node / sources / data / 'jenkins.branch.BranchSource' / source / traits
                traits << 'org.jenkinsci.plugin.gitea.BranchDiscoveryTrait' {
                  strategyId('3')
                }
              }
            }

       Log:

      [Wed Jan 29 02:33:55 GMT 2020] Starting branch indexing...
      ERROR: [Wed Jan 29 02:33:55 GMT 2020] Could not update folder level actions from source 12312313
      hudson.AbortException: Unknown server: SERVER_URL
      	at org.jenkinsci.plugin.gitea.GiteaSCMSource.gitea(GiteaSCMSource.java:570)
      	at org.jenkinsci.plugin.gitea.GiteaSCMSource.retrieveActions(GiteaSCMSource.java:395)
      	at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:848)
      	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:598)
      	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
      	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
      	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1032)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:427)
      [Wed Jan 29 02:33:55 GMT 2020] Finished branch indexing. Indexing took 8 ms
      FATAL: Unknown server: SERVER_URL
      Finished: FAILURE
      

        Attachments

          Issue Links

            Activity

            Hide
            daspilker Daniel Spilker added a comment -

            Joseph Petersen are you still maintaining the CasC plugin? How can we fix this? This there an order between the RootElementConfigurators? Can I just decrease the oridnal of the SeedJobConfigurator extension?

            Show
            daspilker Daniel Spilker added a comment - Joseph Petersen are you still maintaining the CasC plugin? How can we fix this? This there an order between the RootElementConfigurators? Can I just decrease the oridnal of the SeedJobConfigurator extension?
            Hide
            jetersen Joseph Petersen added a comment -

            I would say it's a bug in the Gitea plugin, it should not run validation until someone tries to run the job.

            Show
            jetersen Joseph Petersen added a comment - I would say it's a bug in the Gitea plugin, it should not run validation until someone tries to run the job.
            Hide
            jetersen Joseph Petersen added a comment -

            However I would like to add perhaps the configurator api could benefit from the new milestone.

            Perhaps we could introduce a way delay SeedJobConfigurator to run after These: https://github.com/jenkinsci/configuration-as-code-plugin/pull/1262/files#diff-a366d4f8874702b6d3c2e23825acc7eeR34

            Or otherwise add an even higher load order for those that truely wants to run last.

            Imo SeedJobConfigurator should really and truely RUN LAST

             

            cc Tim Jacomb Oleg Nenashev

            Show
            jetersen Joseph Petersen added a comment - However I would like to add perhaps the configurator api could benefit from the new milestone. Perhaps we could introduce a way delay SeedJobConfigurator to run after These:  https://github.com/jenkinsci/configuration-as-code-plugin/pull/1262/files#diff-a366d4f8874702b6d3c2e23825acc7eeR34 Or otherwise add an even higher load order for those that truely wants to run last. Imo SeedJobConfigurator should really and truely RUN LAST   cc Tim Jacomb Oleg Nenashev
            Hide
            bryanburke Bryan Burke added a comment - - edited

            This problem seems to affect other SCM providers as well, the Atlassian Bitbucket Server Integration plugin in my case. I documented a dirty workaround to inject the clone and browser URLs into the XML via the DSL configure block. See: JENKINS-61210

            Edit: I'm not certain if the same workaround would work for multibranch pipelines.

            Show
            bryanburke Bryan Burke added a comment - - edited This problem seems to affect other SCM providers as well, the Atlassian Bitbucket Server Integration plugin in my case. I documented a dirty workaround to inject the clone and browser URLs into the XML via the DSL configure block. See: JENKINS-61210 Edit : I'm not certain if the same workaround would work for multibranch pipelines.
            Hide
            stephenconnolly Stephen Connolly added a comment -

            Daniel Mecsei this would be a meaty issue to tackle

            You’d need to coordinate with the Config as code project experts

            Show
            stephenconnolly Stephen Connolly added a comment - Daniel Mecsei this would be a meaty issue to tackle You’d need to coordinate with the Config as code project experts
            Show
            jetersen Joseph Petersen added a comment - This should be resolved in v1.41 of Configuration as Code plugin https://github.com/jenkinsci/configuration-as-code-plugin/releases/tag/configuration-as-code-1.41 In exactly this PR https://github.com/jenkinsci/configuration-as-code-plugin/pull/1394  
            Hide
            stephenconnolly Stephen Connolly added a comment -

            Claimed as Fixed in Config as code plugin 

            Show
            stephenconnolly Stephen Connolly added a comment - Claimed as Fixed in Config as code plugin 

              People

              • Assignee:
                jetersen Joseph Petersen
                Reporter:
                thebrokenrail Connor Nolan
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: