hkarthik7 / azure-devops-java-sdk Goto Github PK
View Code? Open in Web Editor NEWJava SDK for managing Azure DevOps services
Home Page: https://azure-devops-java-sdk-docs.readthedocs.io/en/latest/?badge=latest
License: MIT License
Java SDK for managing Azure DevOps services
Home Page: https://azure-devops-java-sdk-docs.readthedocs.io/en/latest/?badge=latest
License: MIT License
Can you add unit tests for org.azd.utils.RestClient class so that I know how it works?
If you had unit tests, hitting a site such as JsonPlaceholder, then I would know how to use the client.
Basically I have a need to query the test/runs endpoint so I can get test result information for builds. Your API does not seem to support that endpoint, documented here: https://learn.microsoft.com/en-us/rest/api/azure/devops/test/runs/list?view=azure-devops-rest-7.0&tabs=HTTP
curl --location --request GET 'https://dev.azure.com/Company/MyTeam/_apis/test/runs?api-version=7.0&includeRunDetails=true&project=MyTeam'
If you don't have any good examples of using your rest client, or any documentation, then I will be forced to use a different 3rd party library. I wanted to keep it simple and use yours, if possible. The arguments that the send methods take are cryptic.
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.
Issue:
The library provides functionality to connect to Azure DevOps services and interact with them using a provided API. However, it seems that there is an issue when attempting to connect to Azure DevOps Server instances using the library's latest version.
Steps to Reproduce:
Create an instance of the library.
Set the base instance URL to the Azure DevOps Server instance: Instance.BASE_INSTANCE.instance = "https://devops.jtaps.us"
Initialize the API using the new method: val webApi = AzDClientApi("JTAPS", pat)
Expected Behavior:
The library should successfully connect to the Azure DevOps Server instance using the provided organization name (collection name in this context) and personal access token (PAT).
Actual Behavior:
When using the new method and providing the organization name (collection name) as 'JTAPS', the following exception is thrown: InvalidOrganizationNameException: Couldn't find the organization name 'JTAPS' in instance 'https://devops.jtaps.us/'.
Additional Information:
It appears that the library's behavior aligns with the naming paradigm used by Azure DevOps services, but it does not accommodate the naming convention used by Azure DevOps Server instances. Azure DevOps Server seems to use a different naming paradigm for organizations (collections) that does not match the organization name provided when initializing the library.
When trying to expand tasks for a release release API is throwing an exception
releaseApi.getRelease(release.getId(), SingleReleaseExpands.TASKS);
ApiResponseParsingException: Unrecognized field "lastRefreshedOn" (class org.azd.distributedtask.types.VariableGroupProviderData), not marked as ignorable (2 known properties: "vault", "serviceEndpointId"])
at [Source: (StringReader); line: 1, column: 290593] (through reference chain: org.azd.release.types.Release["variableGroups"]->java.util.ArrayList[1]->org.azd.release.types.VariableGroup["providerData"]->org.azd.distributedtask.types.VariableGroupProviderData["lastRefreshedOn"])
It's because this is missing the field described in AzureKeyVaultVariableGroupProviderData interface
https://github.com/microsoft/azure-devops-node-api/blob/9ccac86e5bb38c553c433b4e300d920e7e3e2b40/api/interfaces/ReleaseInterfaces.ts#L535
I had some problems with git pushes create and found two problems that are close related.
GitRefUpdate gitRefUpdate = new GitRefUpdate();
gitRefUpdate.setName("refs/heads/test_branch");
ItemContent itemContent = new ItemContent();
itemContent.setContentType(ItemContentType.RAWTEXT);
itemContent.setContent("Content of the file");
GitChange gitChange = new GitChange();
gitChange.setChangeType(VersionControlChangeType.ADD);
gitChange.setItem("/test_file.txt");
gitChange.setNewContent(itemContent);
GitCommitRef gitCommitRef = new GitCommitRef();
gitCommitRef.setComment("Add new test file");
gitCommitRef.setChanges(Collections.singletonList(gitChange));
GitPush gitPush = new GitPush();
gitPush.setRefUpdates(Collections.singletonList(gitRefUpdate));
gitPush.setCommits(Collections.singletonList(gitCommitRef));
gitApi.createPush(repositoryName, gitPush);
The above example results in the following JSON:
{
"_links": null,
"commits": [
{
"_links": null,
"author": null,
"changeCounts": null,
"changes": [
{
"changeId": null,
"changeType": "add",
"item": "/test_file.txt",
"newContent": {
"content": "Content of the file",
"contentType": "rawText"
},
"newContentTemplate": null,
"originalPath": null,
"sourceServerItem": null,
"url": null
}
],
"comment": "Add new test file",
"commentTruncated": false,
"commitId": null,
"committer": null,
"parents": null,
"push": null,
"remoteUrl": null,
"statuses": null,
"url": null,
"workItems": null
}
],
"date": null,
"pushId": null,
"pushedBy": null,
"refUpdates": [
{
"locked": false,
"isLocked": false,
"name": "refs/heads/test_branch",
"newObjectId": null,
"oldObjectId": null,
"repositoryId": null
}
],
"repository": null,
"url": null
}
The new file is added (assuming there is not already a file with this name)
Getting a non descriptive error message:
{
"$id": "1",
"innerException": null,
"message": "The body of the request contains invalid Json.\r\nParameter name: contentStream",
"typeName": "Microsoft.TeamFoundation.SourceControl.WebServer.InvalidArgumentValueException, Microsoft.TeamFoundation.SourceControl.WebServer",
"typeKey": "InvalidArgumentValueException",
"errorCode": 0,
"eventId": 0
}
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.
@Test
void pipelineTest() {
AzDClientApi client = new AzDClientApi(devOpsConfig.getOrganization(),devOpsConfig.getPat());
PipelinesApi pipelinesApi = client.getPipelinesApi();
try {
pipelinesApi.getPipelines().getPipelines().forEach(pipeline -> {
System.out.println(pipeline.getId());
});
} catch (Exception e) {
e.printStackTrace();
}
}
Result:
org.azd.exceptions.AzDException: ApiResponseParsingException: Unrecognized token 'Page': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (String)"Page not found."; line: 1, column: 5]
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:47)
When using the GIT api to get an item from a specific branch, the version is not passed into the URL.
Given that you have a repository "testRepository" with two or more branches where the file "test.txt" has been changed on the "branch-with-changed-file" branch.
GitItems items = gitApi.getItems(
"testRepository",
true,
false,
false,
VersionControlRecursionType.NONE,
"test.txt",
"branch-with-changed-file",
GitVersionOptions.NONE,
GitVersionType.BRANCH);
It will return the file from the "branch-with-changed-file".
It will return the file of the default branch, because the 'version' is not included in the request
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.
Hi,
thanks for this great library.
I was trying to understand if there is a way to call the method to get the team capacity. I looked in the workApi but I didn't find anything.
Here is the link of the method I'm talking about.
Please see the following blog post and community discussion link:
This is to programmatically enable / disable project services such as Boards
, Test Plans
, etc. (see screenshot)
I've confirmed the functionality currently still works.
I'm planning to add this functionality to my app. Since this is not an official published API feature, I'm just confirming if you want me to add this to this library.
If not, I will implement outside, either in my calling app or in my fork only.
Currently SDK doesn't support adding attachments to work items. Please add support for attachments.
Kindly make sure that you have added all the following information above and checkoff the required fields
otherwise the issue template will be treated as an incomplete report.
I seem to have an issue with coreapi.getTeams() service call that works from the raw Azure DevOps API service calls, but seems to be empty on the AzD service.
org.azd.exceptions.AzDException: ApiResponseParsingException: No content to map due to end-of-input
at [Source: (String)""; line: 1, column: 0]
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:59) ~[azd-5.0.10.jar:na]
at org.azd.core.CoreApi.getTeams(CoreApi.java:357) ~[azd-5.0.10.jar:na]
at io.noda.adaptor.azuredevops.domain.AzureAdaptor.getTeams(AzureAdaptor.java:91) ~[classes/:na]
When a raw service call is done at browser:
https://dev.azure.com/rabbitearsvideoproduction/_apis/teams?api-version=7.1-preview.3
{
"value": [
{
"id": "553f1e11-ec5c-4ed3-81cb-71de6365e900",
"name": "The-Mongooses",
"url": "https://dev.azure.com/rabbitearsvideoproduction/_apis/projects/3a335c3a-bad0-4850-b46d-7942d45c239e/teams/553f1e11-ec5c-4ed3-81cb-71de6365e900",
"description": "",
"identityUrl": "https://spsprodcus5.vssps.visualstudio.com/Aff21754c-65bc-40f1-ae29-af385431d22a/_apis/Identities/553f1e11-ec5c-4ed3-81cb-71de6365e900",
"projectName": "Noda-Integration-AzureDevOps-adaptor",
"projectId": "3a335c3a-bad0-4850-b46d-7942d45c239e"
},
{
"id": "91ddb058-fbfb-4a14-b61c-09f8e4d6f1b3",
"name": "Noda-Integration-AzureDevOps Team",
"url": "https://dev.azure.com/rabbitearsvideoproduction/_apis/projects/4fcfd2af-a1da-44ee-bd48-ef80f837ae7d/teams/91ddb058-fbfb-4a14-b61c-09f8e4d6f1b3",
"description": "The default project team.",
"identityUrl": "https://spsprodcus5.vssps.visualstudio.com/Aff21754c-65bc-40f1-ae29-af385431d22a/_apis/Identities/91ddb058-fbfb-4a14-b61c-09f8e4d6f1b3",
"projectName": "Noda-Integration-AzureDevOps",
"projectId": "4fcfd2af-a1da-44ee-bd48-ef80f837ae7d"
},
{
"id": "dad01d92-2ae8-4824-9b2b-1cf4049268ae",
"name": "Noda-Integration-AzureDevOps-adaptor-TeamA",
"url": "https://dev.azure.com/rabbitearsvideoproduction/_apis/projects/3a335c3a-bad0-4850-b46d-7942d45c239e/teams/dad01d92-2ae8-4824-9b2b-1cf4049268ae",
"description": "The default project team.",
"identityUrl": "https://spsprodcus5.vssps.visualstudio.com/Aff21754c-65bc-40f1-ae29-af385431d22a/_apis/Identities/dad01d92-2ae8-4824-9b2b-1cf4049268ae",
"projectName": "Noda-Integration-AzureDevOps-adaptor",
"projectId": "3a335c3a-bad0-4850-b46d-7942d45c239e"
}
],
"count": 3
}
All other service calls seem to be working for me, so I am not completely sure it's PaT authority, but from the code, It looks like it checks for that.
Also there seems to be a data type miss-match with the type on the 4 element Teams Get Call
https://learn.microsoft.com/en-us/rest/api/azure/devops/core/teams/get-all-teams?view=azure-devops-rest-7.1&tabs=HTTP
$mine is boolean on MS Azure DevOps API and is string in the AzD library
Most of the examples have the code authenticating with Azure via a PAT (Personal Access Token) but the application I'm writing runs as a background agent and syncs Azure with another system. I saw in the Connection class there is a way to pass the AuthorizedToken object to get an OAuth connection but I wasn't 100% sure if I had the steps correct (starting with OAuthApi.getAuthorizationEndpoint?).
Do you have a Java sample of how to connect via OAuth you could post? I currently have the tenant Id, client id and client secret of the application as defined in Azure. Do I need other pieces of information?
Add ability to get Retry-After value in response header.
When making a large number of API calls in a short period of time (such as creating new Releases) that cause one to exceed Azure limits on CPU usage via API usage, and before the request(s) get delayed / denied the server will return a Retry-After value in the response header.
I will open a pull request that can achieve this using minimal code changes, but am open to a better way of doing this too :-)
Looks like "organization" is a valid ProjectVisibility?
org.azd.exceptions.AzDException: ApiResponseParsingException: Cannot deserialize value of type org.azd.enums.ProjectVisibility
from String "organization": not one of the values accepted for Enum class: [public, private, unchanged]
// get the list of projects
core.getProjects();
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.
Hi,
We get this error:
org.azd.exceptions.AzDException: ApiResponseParsingException: Cannot construct instance of org.azd.build.types.ValidationResult
(although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('error')
at [Source: (StringReader); line: 1, column: 5734] (through reference chain: org.azd.build.types.Builds["value"]->java.util.ArrayList[1]->org.azd.build.types.Build["validationResults"]->java.util.ArrayList[0]->org.azd.build.types.BuildRequestValidationResult["result"])
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:49) ~[azd-5.0.4.jar:?]
When trying to get builds. This occurs when we have a pipeline run that failed to start (by errors in yaml syntax or, in this case service account suspended).
Response from azure devops:
"validationResults": [
{
"result": "error",
"message": "The pipeline is not valid. Could not get the latest source version for repository XXXX hosted on https://github.com/ using ref refs/tags/v3. GitHub reported the error, \"Sorry. Your account was suspended.\""
}
],
Run a pipeline with invalid yaml or service account disabled.
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.
Hi, first of all, thank you for your work, it's amazing!
Using this library, I have found that it's missing the Pull Request Statuses object (i.e. GitPullRequestStatus[es]), to get the status of a pull request's checks.
I refer to this:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-request-statuses?view=azure-devops-rest-7.0
having this, would be possible to list the pull request statuses:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-request-statuses/list?view=azure-devops-rest-7.0&tabs=HTTP
or get a specific pull request status:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-request-statuses/get?view=azure-devops-rest-7.0&tabs=HTTP
And it would help to verify a pull request check.
One more time: thank you for your work!
Hi
First thanks for this project very helpful and very clean code!!!!
I saw in the code that there are some calls that do support the continuation token as a param but I was wondering if you return the next continuation token in the response as well so it can be used in the next call?
Thanks again
Hi,
I need to fetch which stages there are for a pipeline run and their statuses.
For example I want to get if the Test and Prod stages was succeeded or not for an runId.
I tried to search the source but as far as I could see this is not supported?
I can help implementing this but could appreciate some hints in where it should be implemented and naming conventions etc.
Kindly make sure that you have added all the following information above and checkoff the required fields
otherwise the issue template will be treated as an incomplete report.
A parsing exception occurs when getting a ReleaseDefinition that has an an Environment that has Conditions. Exception below:
org.azd.exceptions.AzDException: ApiResponseParsingException: Cannot construct instance of org.azd.release.types.ConditionType
(although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('event')
at [Source: (StringReader); line: 1, column: 11013] (through reference chain: org.azd.release.types.ReleaseDefinition["environments"]->java.util.ArrayList[0]->org.azd.release.types.ReleaseDefinitionEnvironment["conditions"]->java.util.ArrayList[0]->org.azd.release.types.Condition["conditionType"])
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:49)
at org.azd.release.ReleaseApi.getReleaseDefinition(ReleaseApi.java:430)
Will submit a PR for this as the fix is simple. We should be using the corresponding enum instead of a class.
Create a Release Definition that has an Environment that has one ore more conditions.
No exception should occur (and the Release Definition should be successfully fetched/parsed from server
Exception occurs
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.
With version 5.0.2 the API parsing fails for an expanded release with tasks. This is due to Jackson failing to deserialize the ConditionType in the release condition.
This is call
Release expandedRelease = azDClientApi.getReleaseApi().getRelease(release.getId(), SingleReleaseExpands.TASKS);
is throwing
ApiResponseParsingException: Cannot construct instance of `org.azd.release.types.ConditionType` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('event')
at [Source: (StringReader); line: 1, column: 3340] (through reference chain: org.azd.release.types.Release["environments"]->java.util.ArrayList[0]->org.azd.release.types.ReleaseEnvironment["conditions"]->java.util.ArrayList[0]->org.azd.release.types.ReleaseCondition["conditionType"])
The error comes down to the class org.azd.release.types.Condition referencing org.azd.release.types.ConditionType but the expected result for API version 7.1 is an enum
ConditionType enum
See conditionType here in json response
"conditions": [
{
"result": false,
"name": "ReleaseStarted",
"conditionType": "event",
"value": ""
},
Version 6.0
introduces some breaking changes to the library. This is a complete re-write to make azd
more robust, easy to extend and use. Currently azd
uses single Client Api
class per Azure DevOps Api
(such as BuildApi
, CoreApi
, GitApi
etc..), this is splitted into request builders to provide a declarative syntax and fluent Api style coding experience with single client
instance to construct and execute the request.
Api | Link | Details |
---|---|---|
Connection |
Connection | Deprecated |
AzDAsyncApi |
AzDAsyncApi | Deprecated |
BaseRestClient |
BaseRestClient | Deprecated |
RestClient |
RestClient | Deprecated |
RestClientProvider |
RestClientProvider | Deprecated |
JsonMapper |
JsonMapper | Deprecated |
AzDService |
AzDService | New |
OAuthAccessTokenBuilder |
OAuthAccessTokenBuilder | New |
AccessTokenCredential |
AccessTokenCredential | New |
ClientRequest |
ClientRequest | New |
v6.0
brings new features and functionalities.
interface
provides the functionality of choosing the authentication provider. Currently azd
supports Personal access token and OAuth on-behalf of authentication.interface
provides the serialization
and deserialization
functionalities.getNextPageLink()
method which returns next page based link if continuation token is found in the header.Note that, some Apis return link:rel=next; in the header and it is not managed by getNextPageLink()
method. Instead use getResponse().getResponseHeaders()
which returns the HttpResponseHeader
object to retrieve the URL.
authentication provider
.Legacy Apis
such as BuildApi
, GitApi
or CoreApi
, the client object created using AzDServiceClient can be used to construct the requests and get the response back. See below for example.With the help of community contributors the functionalities of azd
has grown huge, to make the code base maintaintable, easy to use, and align the usage more close to Azure DevOps Api
. Also, v6.0
introduces declarative syntax to query the Api.
A glimpse of the usage:
// 1. Choose the authentication provider;
// AccessTokenCredential interface has few implementations.
// --> PersonalAccessTokenCredential - Use with your personal access token.
// --> OAuthAccessTokenCredential - Use for on-behalf of user and generate access token aka jwt.
// --> OAuthAccessTokenCredential provides automatic token refresh functionality.
// For Azure DevOps Services or TFS server the authentication provider object can be created as below
// https://dev.azure.com/{organization}
// https://server:port/tfs/{collection}
var oauthTokenCredential = new OAuthAccessTokenCredential(organizationUrl, projectName, appSecret, authCode, callbackUrl);
var personalAccessTokenCredential = new PersonalAccessTokenCredential(organizationUrl, project, personalAccessToken);
// 2. Create the client object with choosen authentication provider.
AzDServiceClient client = AzDService.builder()
.authentication(personalAccessTokenCredential)
.buildClient();
//or
AzDServiceClient client = AzDService.builder()
.authentication(oauthTokenCredential)
.buildClient();
// Single client instance and declarative syntax.
client.core().projects().list();
// Usage with query parameters.
client.core().projects().list(config -> {
config.queryParameters.top = 100;
config.queryParameters.stateFilter = ProjectState.ALL;
config.queryParameters.getDefaultTeamImageUrl = true;
config.queryParameters.skip = 10;
});
// All the Apis have overloaded methods that returns a CompletableFuture<> object.
client.core().projects().listAsync();
Legacy Apis
are not going to change and will remain as is, indeed the internal implementations are going to change. The Legacy Apis
will implement the new functionalities internally thus providing same output as before. Due to the deprecation of Apis
that are used by Legacy Apis
a minimal code change is required if you're using any of the Deprecated Apis. It is highly recommended that you move to new implementation.
PS: Latest code can be found here.
If retrieving repositories with where the size of the repository is rather large, then the JSON object mapping fails with the following exception:
Exception in thread "main" org.azd.exceptions.AzDException: ApiResponseParsingException: Numeric value (39027429139) out of range of int (-2147483648 - 2147483647)
at [Source: (StringReader); line: 1, column: 261214] (through reference chain: org.azd.git.types.Repositories["value"]->java.util.ArrayList[270]->org.azd.git.types.Repository["size"])
Run the following Java code:
public class Example {
public static void main(String[] args) throws AzDException {
var organisation = "<my org>";
var personalAccessToken = "<access code>";
var webApi = new AzDClientApi(organisation, personalAccessToken);
var core = webApi.getCoreApi();
System.out.println(webApi.getGitApi().getRepositories());
}
}
Have a large Git repository. For example the following JSON response on the repositories API:
{
"value": [
...
{
"id": "<private>",
"name": "<private>",
"url": "<private>",
"project": {
...
},
"size": 39027429139,
...
}
...
]
}
Status code 0
Exception was raised by `JsonMapper`
Kindly make sure that you have added all the following information above and checkoff the required fields
otherwise the issue template will be treated as an incomplete report.
This is a wonderful library and I'm using it weekly to extract a bunch of interesting insights for my organization - thank you!
One thing I noticed about GitApi's getRepositories() method is that it doesn't allow one to set the includeHidden switch, which I believe is necessary to include Wiki repos in search results without calling getRepository(repoName) explicitly. This means I have to perform a few more steps to search for Wikis, then iterate through each one to get the remote URLs for further cloning and analysis. Someone else may also like to specify includeAllUrls and includeLinks as well, so I'm wondering if you could leave the existing getRepositories() method alone and add a convenience method that accepts those three switches?
Thank you in advance - this is a genuinely useful library! - Scott
Hi,
I had a look at the documentation, but I am not finding anything, so I just want to ask the question in case I missed something : the API mentions that we can browse a repository content (see https://docs.microsoft.com/en-us/rest/api/azure/devops/build/source-providers/get-file-contents?view=azure-devops-rest-6.0 ), but that feature is not there (yet ?) in the SDK, right ?
thanks
When calling the git API, the getCommits()
always returns null:
AzDClientApi webApi = new AzDClientApi(Constants.ORGANIZATION_NAME, Constants.PROJECT_NAME, Constants.PERSONAL_ACCESS_TOKEN);
GitApi git = webApi.getGitApi();
PullRequests pullRequests = git.getPullRequests(Constants.REPO_NAME);
List<GitPullRequest> gitPullRequests = pullRequests.getPullRequests();
if (gitPullRequests == null) {
return;
}
for (GitPullRequest gitPullRequest : gitPullRequests) {
List<GitCommitRef> commits = gitPullRequest.getCommits();
// commits is always null
i tried with 5.0.10 and i also tried with 6.0.0-SNAPSHOT.
what am i doing wrong?
my goal is, to get all changed files from a pull request, to analyze the path of the files and add labels.
adding labels works fine:
git.createPullRequestLabel(Constants.REPO_NAME, gitPullRequest.getPullRequestId(), "azd-tooling-test-feature-xyz");
Hi, first of all: thank you for your work! :)
Your library was helpful, same way as your examples.
When I started to use your library, it was helpful this example document:
https://github.com/hkarthik7/azure-devops-java-sdk/blob/main/examples/GitApi.md
I detected some lack of examples. For example, some examples to do a simple case, as:
or
4. delete branch from point 2
it would be nice to have this kind of examples in the file.
as example:
// create branch
var git = webApi.getGitApi();
String newBranch = "branch_name";
String mainBranchId = git.getBranch(repositoryName, branchName).getObjectId();
String oldBranchId = "0000000000000000000000000000000000000000"; // Azure rules ¯_(ツ)_/¯
GitRefUpdateResult gitRefUpdateResult = git.updateRef(repositoryName, "refs/heads/" + newBranchName, oldBranchId, mainBranchId);
// commit
GitPush gitPush = new GitPush();
gitPush.setCommits(gitCommitRefList);
gitPush.setRefUpdates(gitRefUpdateList);
git.createPush(repoId, gitPush);
// create pull request
GitPullRequest gitPullRequest = new GitPullRequest();
gitPullRequest.setDescription("PR test description");
gitPullRequest.setIsDraft(false);
gitPullRequest.setLabels(new ArrayList<>());
gitPullRequest.setReviewers(new ArrayList<>());
gitPullRequest.setSourceRefName("refs/heads/" + newBranch);
gitPullRequest.setTargetRefName("refs/heads/main");
gitPullRequest.setTitle("PR title");
gitPullRequest.setRepository(repository);
GitPullRequest gitPullRequestOutput = git.createPullRequest(gitPullRequest);
// delete branch
String deleteBranchId = "0000000000000000000000000000000000000000"; // Azure rules ¯_(ツ)_/¯
String oldObjectId = git.getBranch(sepositoryName, branchToDeleteName).getObjectId();
gitRefUpdateResult = git.updateRef(repositoryName, "refs/heads/" + branchToDeleteName, oldObjectId, deleteBranchId);
Currently the library is using API version 6.0, this will be migrated soon to match the new version 7.1.
Hello.
Azure Devops Rest API does not provide Create/Delete Tag(not annotate) or Create/Delete Branch.
However, it can be implemented through updateRefs, Is it ok if I implement the method?
Below is the expected implementation.
Kindly make sure that you have added all the following information above and checkoff the required fields
otherwise the issue template will be treated as an incomplete report.
Hi Karthik,
Thanks for the hard work!
I think this is a great azure devops java library
I was wondering if there'll be support for Android?
Have a nice day!
The current SDK can only connect to Azure DevOps in the cloud - looking at the code this looks like it is due to the Instance.BASE_INSTANCE value hard-coded to 'BASE_INSTANCE("https://dev.azure.com/")'
This value in-turn is used by RestClientProvider getLocationUrl(String resourceID, String organizationName) method that is used to connect to the ADO endpoints
As the various connection APIs mainly pass the organizationName and projectName parameters and changing the signature will be cumbersome and invasive a hack could be just changing the getLocationUrl method - if the organizationName is a full url (starting with https://....) you could keep the value unchanged otherwise prepend with the BASE_INSTANCE
my definitionId is 162
queue build like in the example
build.queueBuild(162);
works
but with parameters not.
java sample code
var parameters = new HashMap<String, Object>();
BuildDefinition def = new BuildDefinition();
def.setId(162);
parameters.put("definition", def);
parameters.put("key1", "value1");
build.queueBuild(parameters);
build triggered with parameter
Message
DefinitionNotFoundException: Build pipeline 162 was not found.
Is there a way to push changes like https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pushes/create?view=azure-devops-rest-7.0&tabs=HTTP#update-a-file-in-a-new-branch?
When building azd from the command line using Maven it requires that Java 11 or higher is used to build the jar.
The problem I'm having is I would like to use the jar as part of a script library in HCL Domino however unfortunately the latest release (Domino 12.0.2) only supports up to Java 8 so when the jar is loaded it errors out.
Is there any way the azd jar could be built with Java 8 (even if I had to lose some functionality)? I only need the WorkItem/WorkItemTracking functionality to sync issues from a Notes-based database to Azure DevOps.
Hello,
our sonar firewall is blocking your jars because of CVE "sonatype-2022-6438"
can you please update jackson version.
thanks
I'm tring to clone a very large repository ( ~30Gb ) but I got the following error :
org.azd.exceptions.AzDException: ApiResponseParsingException: Numeric value (30134050676) out of range of int (-2147483648 - 2147483647)
at [Source: (String)"{"id":"7dc78671-3aca-4f78-adb7-06d5c183a1cb","name":"XXXX","url":"XXXX","project":{"id":"XXXXX","name":"XXXXX","description":"XXXXX","url":"XXXXX","state":"wellFormed","revision":2665,"visibility":"priva"[truncated 1531 chars]; line: 1, column: 604] (through reference chain: org.azd.git.types.GitRepository["size"])
at org.azd.helpers.JsonMapper.mapJsonResponse(JsonMapper.java:49) ~[azd-5.0.6.jar:na]
at org.azd.git.GitApi.getRepository(GitApi.java:135) ~[azd-5.0.6.jar:na]
Library version : 5.0.6
This issue is the same reported here : #13
Possible solution : change the type of the size field from Integer to Long in class GitRepository ( package org.azd.git.types )
AzDClientApi azDClientApi = new AzDClientApi("xxxx", "xxxxx", "xxxxx");
GitRepository gitRepository = azDClientApi.getGitApi().getRepository(""); // repository size must be > 2Gb
No Exception raised and the JSON provided by Azure DevOps is correctly mapped in the GitRepository class
Exception org.azd.exceptions.AzDException: ApiResponseParsingException raised
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise the
issue template will be treated as an incomplete report.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.