Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jenkins-zh/jenkins-client-java
Java实现的对Jenkins操作
https://github.com/jenkins-zh/jenkins-client-java
client java jenkins
Last synced: 12 days ago
JSON representation
Java实现的对Jenkins操作
- Host: GitHub
- URL: https://github.com/jenkins-zh/jenkins-client-java
- Owner: jenkins-zh
- License: mit
- Created: 2017-11-22T03:08:53.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-11-16T09:24:58.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T18:44:42.642Z (about 1 month ago)
- Topics: client, java, jenkins
- Language: Java
- Homepage: https://jenkins-zh.cn
- Size: 163 KB
- Stars: 30
- Watchers: 2
- Forks: 20
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.surenpi/jenkins.client.java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.surenpi/jenkins.client.java)
# jenkins-client-java
Java binding for the Jenkins client.
[sonar](https://sonarcloud.io/dashboard?id=com.surenpi.ci%3Ajenkins.client.java)
# How to use it
Add the following dependency to the pom.xml file of your project:
```xml
com.surenpi.ci
jenkins.client.java
1.0.0-20171217```
# Example of get all jobs from jenkins```java
import com.surenpi.jenkins.client.Jenkins;import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;/**
* @author suren
*/
public class Demo
{
public static void main(String[] args) throws URISyntaxException, IOException
{
URI serverURI = new URI("http://localhost:8080/jenkins");
Jenkins jenkins = new Jenkins(serverURI, "admin", "admin");Jobs jobMgr = jenkins.getJobs();
List allJobs = jobMgr.getAllJobs();for(Job job : allJobs)
{
System.out.println(job.getName());
}
}
}
```# Example of get all installed plugins from jenkins
```java
import com.surenpi.jenkins.client.Jenkins;
import com.surenpi.jenkins.client.plugin.Plugin;
import com.surenpi.jenkins.client.plugin.Plugins;import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;/**
* @author suren
*/
public class Demo
{
public static void main(String[] args) throws URISyntaxException, IOException
{
URI serverURI = new URI("http://localhost:8080/jenkins");
Jenkins jenkins = new Jenkins(serverURI, "admin", "admin");Plugins pluginMgr = jenkins.getPlugins();
List allInstalledPlugins = pluginMgr.getPluginManager().getPlugins();
for(Plugin plugin : allInstalledPlugins)
{
System.out.println(plugin.getShortName());
}
}
}
```# Example of get all credentials from jenkins
```java
import com.surenpi.jenkins.client.Jenkins;
import com.surenpi.jenkins.client.credential.Credential;
import com.surenpi.jenkins.client.credential.Credentials;import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Map;/**
* @author suren
*/
public class Demo
{
public static void main(String[] args) throws URISyntaxException, IOException
{
URI serverURI = new URI("http://localhost:8080/jenkins");
Jenkins jenkins = new Jenkins(serverURI, "admin", "admin");Credentials credentialMgr = jenkins.getCredentials();
Map credentialMap = credentialMgr.list();
for(String key : credentialMap.keySet())
{
System.out.println(credentialMap.get(key).getDescription());
}
}
}
```# Compile & Package
If you want to compile project, you can via `mvn clean compile`
If you want to package project and skip the junit test, you can via `mvn clean package -DskipTest`