How can I get system configuration for jenkins using remote access API

Jenkins provides a good remote access API that you can use to get a lot of information, such as tasks and views.

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

This data can be found at http: //your.jenkins.url/manage

+7
api jenkins
source share
3 answers

You can set your wizard / nodes configuration via

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

Is this good enough for you?

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

To learn more about the API, try adding / api at the end of some URLs.

To find which objects the API exposes, do a _api.jelly search at https://github.com/jenkinsci/jenkins/find/master (press 't', then enter '_api.jelly')

+11
source share

For specific information about the system configuration, such as all environment variables, etc., and not what was requested in the description, but the title, you want to add / systemInfo to the end of your URL.

 http:<YourURLHere>/systemInfo 

Then you will need to pass some authentication, and then you will be presented with a list of data in HTML format. So you will need a little parsing, as if you were using grep, it would just return the whole table.

 http://fakeurl.com/systemInfo --user 'fakeuser':'fakepasswd' 
+1
source share

In my plugin, I got access to the Artifactory Credentials system configuration. 1) add artifactory dependency to 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 configuration 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) define the class used to apply the configuration. org.jfrog.hudson.ArtifactoryBuilder.java 4) create an instance of jenkins and access the plugin descriptor, get user credentials.

 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(); 
0
source share

All Articles