Jenkins提供了很好的Remote Access API,它可用於獲取大量信息,如作業和視圖。如何使用遠程訪問API獲取jenkins的系統配置
我想知道是否或如何從遠程訪問API中獲取系統(全局)配置。
這些信息在網頁http://your.jenkins.url/manage
Jenkins提供了很好的Remote Access API,它可用於獲取大量信息,如作業和視圖。如何使用遠程訪問API獲取jenkins的系統配置
我想知道是否或如何從遠程訪問API中獲取系統(全局)配置。
這些信息在網頁http://your.jenkins.url/manage
你可以得到你的主/節點通過
http://your.jenkins.url/computer/(master)/config.xml
的配置是對你不夠好?
注:自2014年中以來,POSTing has been disabled。
要了解更多關於API的信息,請嘗試在某些URL的末尾添加/ api。
爲了找到哪些對象暴露的API,在https://github.com/jenkinsci/jenkins/find/master搜索_api.jelly(按「T」然後輸入「_api.jelly」)
是的,這是驚人的!你怎麼知道這個? ;-),你能列出你得到這些信息的位置嗎? –
@LarryCai找到瀏覽http://your.jenkins.url/computer/(master)/ api的信息。在如何查找更多API信息的答案中增加了更多信息。 – coffeebreaks
真棒,現在我知道幾乎所有的API –
對於具體的系統配置信息,例如所有FO的環境變量和這樣,而不是你的描述所要求的,但標題,你會想要追加/ systemInfo到你的URL的末尾。
http:<YourURLHere>/systemInfo
然後,你必須通過一些身份驗證,然後你應該被提供一個HTML列表的信息。所以你必須做一些解析,就像你使用grep一樣,它只會返回整個表。
http://fakeurl.com/systemInfo --user 'fakeuser':'fakepasswd'
在我的插件中,我訪問了系統配置「Artifactory credentials」。 1)在pom.xml中添加artifactory依賴項。 即
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>artifactory</artifactId>
<version>2.9.0</version>
<type>jar</type>
</dependency>
2)找到確切的加工global.jelly配置。 i的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)識別用於施加配置的類。 org.jfrog.hudson.ArtifactoryBuilder.java 4)創建jenkins實例並訪問插件描述符獲取用戶憑證。
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();
類似的問題http://stackoverflow.com/questions/7064119/expose-hudson-system-info-to-remote-api –