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

programatically add GitHub Enterprise Servers in Jenkins

    Details

    • Similar Issues:

      Description

       
      Hi,

       

      I cannot reproduce programatically this action: Manage Jenkins -> Configure System -> GitHub Enterprise Servers -> Add

      How can I do this in groovy?

      My attempt is:

      import org.jenkinsci.plugins.github_branch_source.Endpoint
      import org.jenkinsci.plugins.github_branch_source.GitHubConfiguration
      
      Endpoint endpoint = new Endpoint("http://test.com", "test")
      GitHubConfiguration ghc = new GitHubConfiguration()
      ghc.addEndpoint(endpoint)
      ghc.save()

      But it doesnt create required configuration.

       UPDATE
      in jenkins_home directory I can see file 

      org.jenkinsci.plugins.github_branch_source.GitHubConfiguration.xml with following content:

      <?xml version='1.1' encoding='UTF-8'?>
      <org.jenkinsci.plugins.github__branch__source.GitHubConfiguration plugin="github-branch-source@2.3.6">
        <endpoints>
          <org.jenkinsci.plugins.github__branch__source.Endpoint>
            <name>test</name>
            <apiUri>http://test.com</apiUri>
          </org.jenkinsci.plugins.github__branch__source.Endpoint>
        </endpoints>
      </org.jenkinsci.plugins.github__branch__source.GitHubConfiguration>

      But I still cannot see anything in Jenkins -> Manage Jenkins page.

        Attachments

          Activity

          Hide
          spugachev Stanislav Pugachov added a comment - - edited

          I managed to do it:

          import org.jenkinsci.plugins.github_branch_source.Endpoint
          import jenkins.model.Jenkins
          def inst = Jenkins.getInstance()    
          def desc = inst.getDescriptor("org.jenkinsci.plugins.github_branch_source.GitHubConfiguration")
          desc.endpoints = [new Endpoint("https://github.<mycompany>.com/api/v3", "<mycompany>")];
          desc.save();

          I don't know if it is a proper way to do this, but anyway

          Show
          spugachev Stanislav Pugachov added a comment - - edited I managed to do it: import org.jenkinsci.plugins.github_branch_source.Endpoint import jenkins.model.Jenkins def inst = Jenkins.getInstance() def desc = inst.getDescriptor("org.jenkinsci.plugins.github_branch_source.GitHubConfiguration") desc.endpoints = [new Endpoint("https://github.<mycompany>.com/api/v3", "<mycompany>")]; desc.save(); I don't know if it is a proper way to do this, but anyway

            People

            • Assignee:
              lanwen Kirill Merkushev
              Reporter:
              spugachev Stanislav Pugachov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: