azd library helps to manage Azure DevOps REST API with ease. This provides functionality to the significant services in Azure DevOps and manage in granular level.
You can view the blog post for details about the library.
To download the library and use it in your project, just add below in your pom.xml file.
<dependency>
<groupId>io.github.hkarthik7</groupId>
<artifactId>azd</artifactId>
<version>${latest Version}</version>
</dependency>Java docs
<dependency>
<groupId>io.github.hkarthik7</groupId>
<artifactId>azd</artifactId>
<version>${latest Version}</version>
<classifier>javadoc</classifier>
</dependency>Source jar
<dependency>
<groupId>io.github.hkarthik7</groupId>
<artifactId>azd</artifactId>
<version>${latest Version}</version>
<classifier>sources</classifier>
</dependency>- Get the list of projects for your organisation
public class Main {
public static void main(String[] args) {
String organisation = "myOrganisationName";
String personalAccessToken = "accessToken";
// Connect Azure DevOps API with organisation name and personal access token.
var webApi = new AzDClientApi(organisation, personalAccessToken);
// call the respective API with created webApi client connection object;
var core = webApi.getCoreApi();
try {
// get the list of projects
core.getProjects();
// create a new project
core.createProject("my-new-project", "Finance management");
// create a team in the project
core.createTeam("my-new-project", "my-new-team");
// list all the teams
core.getTeams();
} catch (AzDException | ConnectionException e1) {
e1.printStackTrace();
}
}
}- Easily clone a build pipeline
public class Main {
public static void main(String[] args) {
String organisation = "myOrganisationName";
String personalAccessToken = "accessToken";
String projectName = "myProject";
// Connect Azure DevOps API with organisation name and personal access token.
var webApi = new AzDClientApi(organisation, projectName, personalAccessToken);
// call the respective API with created webApi client connection object;
var build = webApi.getBuildApi();
try {
// Clone an existing pipeline with the pipeline name
String ciName = "DeployTo-WebApp-CI";
String ciCloneName = "DeployTo-WebApp-CI-Copy";
build.cloneBuildDefinition(ciName, ciCloneName);
} catch (AzDException | ConnectionException e1) {
e1.printStackTrace();
}
}
}| NAME | VERSION |
|---|---|
| com.fasterxml.jackson.core | v2.12.0 |
You are going to need JDK version 11 or above and can be downloaded from here.
Download Maven from the official website. Once it is installed add JAVA_HOME to the path as Maven is
going to need it. You can check if Maven is installed correctly by running mvn -v.
Once you have installed JDK and Maven you can then,
Clone the repository and navigate to root of the folder where pom.xml is placed.
- Run
mvn cleanto clean the target folder if any exists - Update
_unitTest.jsonwith your organisation name, project name and personal access token. - Run
mvn testto run unit tests - Run
mvn packageto install the dependencies and create the resultant.jarfile.
This project is licensed under MIT