12

Jenkins provide nice Remote Access API, which can be used to fetch lots of information like jobs and views.

I wonder whether or how to fetch the system (global) configurations from remote access API.

Those information are in web page http://your.jenkins.url/manage

Larry Cai
  • 55,923
  • 34
  • 110
  • 156

3 Answers3

18

You can GET the config of your master / nodes through

http://your.jenkins.url/computer/(master)/config.xml

Is that good enough for you ?

Note: since mid-2014, POSTing has been disabled.

To find more about APIs, try adding /api to the end of some URLs.

To find which objects expose APIs, search for _api.jelly in https://github.com/jenkinsci/jenkins/find/master (press 't' then type '_api.jelly')

coffeebreaks
  • 3,787
  • 1
  • 26
  • 25
3

For specifically system configuration information, such as all fo the environment variables and such, not what your description was asking for but the title, you'll want to append /systemInfo to the end of your URL.

http:<YourURLHere>/systemInfo

Then you'll have to pass some authentication to it and then you should be presented with an HTML listing of the information. So you'd have to do some parsing, as if you use grep, it'll just return the entire table.

http://fakeurl.com/systemInfo --user 'fakeuser':'fakepasswd'
FilBot3
  • 3,460
  • 6
  • 33
  • 55
0

In my plugin i have accessed the system configuartion,"Artifactory credentials". 1) add the artifactory dependency in pom.xml. i.e.

<dependency>
            <groupId>org.jenkins-ci.plugins</groupId>
            <artifactId>artifactory</artifactId>
            <version>2.9.0</version>
            <type>jar</type>
        </dependency>

2) find the exact maching global.jelly config. i found in org.jfrog.hudson.ArtifactoryBuilder

                            <table style="width: 100%" id="legacyDeployerCredentials${server.url}">
                                <f:entry title="Username"
                                         help="/plugin/artifactory/help/common/help-deployerUserName.html">
                                    <f:textbox name="username" field="username"
                                               value="${server.deployerCredentialsConfig.username}"/>
                                </f:entry>
                                <f:entry title="Password"
                                         help="/plugin/artifactory/help/common/help-deployerPassword.html">
                                    <f:password name="password" field="password"
                                                value="${server.deployerCredentialsConfig.password}"/>
                                </f:entry>
                            </table>
                        </f:block>
                    </f:section>

3) identify the class used for applying the configuration. org.jfrog.hudson.ArtifactoryBuilder.java 4) create jenkins instance and access the plugin descriptor get user credential.

ArtifactoryBuilder.DescriptorImpl ab = (ArtifactoryBuilder.DescriptorImpl) jenkins.model.Jenkins.getInstance().getDescriptor(ArtifactoryBuilder.class);
        ArtifactoryServer server = ab.getArtifactoryServers().iterator().next();
        this.userName =  server.getDeployerCredentialsConfig().getUsername();
        this.password =  server.getDeployerCredentialsConfig().getPassword();