I am trying to dynamically create environments with a set of specific predefined tasks and steps.
Anyone ever got this working well enough to post some sample code, or a guide?
I can't add an environment, or tasks to an existing one. I keep getting an error BadRequest, but I don't know what am I doing wrong in the JSON payload.
I can get the existing definition, I can do simple things like update the name of the release definition, comments and description when I update, but once I touch the environments it all breaks.
I am using the online URIs -
https://vsrm.dev.azure.com/{acct}/{proj}/_apis/release/definitions?api-version=5.1
Is there any way to get more information on what's wrong with my payload, what's bare minimum, or required?
If you mean create/update environment for the specific release definition, then you can try the following steps:
Get that release definition response and convert the response to JSON body:
GET https://vsrm.dev.azure.com/{organization}/{Project}/_apis/release/definitions/{definition ID}?api-version=5.1
Add (insert) a new environment (or update the existing one) to that JSON body. You can copy from the existing environment block, then change the parameters accordingly. For example: Add a new environment with "id":0, set a new name, the ranks of release pipeline stages need to be consecutive natural numbers, for example, the rank in previous stage is "2", then it should be "3" here. Keep others same as previous one
Update the release definition by calling the REST API with the updated JSON body:
PUT https://vsrm.dev.azure.com/{organization}/{Project}/_apis/release/definitions?api-version=5.1
You can reference the below screenshot for details:
Related
I know one can use REST API to query Pipeline activities but is there anyway to query Pipeline components ( i.e, listing of linked services, sources, sinks, parameters, etc.)
Right now I'm manually recording all the components I see in the pipeline and querying these components would make this listing faster and more accurate
enter image description here
Thanks, Jeannie
I haven't found a way to get all the components of a pipeline directly. If the information you want to obtain is defined in the YAML file, you cannot directly obtain it, you may need to parse the YAML file to obtain it.
If the information you want to get is defined on the UI, such as variables, you can get it through the REST API Definitions - Get. And you can get the resources of the pipeline through Resources - List.
I am trying to collect some metrics on releases in Azure Devops via a Powershell script.
I have very limited dev experience and am new to PowerShell. And this is the first time I have worked with an API. So far I have been able to authenticate, return a list of releases, loop through them and export the data to a file. Now I need to filter the releases based on a substring of the release name. For the record I have been doing my initial testing in Postman to make sure my syntax and results are correct. Then I migrated working syntax to Powershell.
https://{{organization}}.vsrm.visualstudio.com/{{project}}/_apis/release/releases?api-version=5.0
If I add the id filter as shown here:
https://{{organization}}.vsrm.visualstudio.com/{{project}}/_apis/release/releases?api-version=5.0&releaseId=34567
I get this result:
"id": 34567,
"name": "Test-Release-MyService",
But if use the same filter format for Release Name,
https://{{organization}}.vsrm.visualstudio.com/{{project}}/_apis/release/releases?api-version=5.0&releaseName="Test-Release-MyService"
I get back 50 results of which none match that criteria, whether I wrap the string in quotes or not. Furthermore, what i really want to do is to have the response only include records where the releaseName contains "XYZ".
So the question: Is there a filter operator for "contains" so I only get back records where the release name contains the "XYZ" substring?
Thanks in advance for your advice.
Every parameter you used in Azure DevOps REST API needs to be consistent with the description in the document, Azure DevOps REST API does not support custom parameters. For your question, the parameter searchText is used to filter the the searching result with the release name containing the keyword. I have tested with POSTMAN to call the api, it works fine. In addition, the value of parameter searchText is not case-sensitive. Filter release name
If you want to do more filter, in fact you can use powershell or other client library to deserialize the json response to an object, and do some convert or filter. Following documents may be helpful for you:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/convertfrom-json?view=powershell-6
https://devblogs.microsoft.com/scripting/playing-with-json-and-powershell/
I'm attempting to pull data from the Square Connect v1 API using ADF. I'm utilizing a Copy Activity with a REST source. I am successfully pulling back data, however, the results are unexpected.
The endpoint is /v1/{location_id}/payments. I have three parameters, shown below.
I can successfully pull this data via Postman.
The results are stored in a Blob and are as if I did not specify any parameters whatsoever.
Only when I hardcode the parameters into the relative path
do I get correct results.
I feel I must be missing a setting somewhere, but which one?
You can try setting the values you want into a setVariable activity, and then have your copyActivity reference those variables. This will tell you whether it is an issue with the dynamic content or not. I have run into some unexpected behavior myself. The benefit of the intermediate setVariable activity is twofold. Firstly it coerces the datatype, secondly, it lets you see what the value is.
My apologies for not using comments. I do not yet have enough points to comment.
TL;DR: How do I relate a release to the tests visible in the Tests tab via the API?
I am running a Release Pipeline which executes tests against the website being deployed. The tests generate files (within my test code) and I want to use the DevOps REST API to attach those files to the Test report associated with the Release.
Note: I am running these tests as smoke tests after release as part of the release pipeline so that I can test the deployed website. This would not be possible as part of the build pipeline.
I can get the release information, but I'm having trouble identifying how to find the related test(s) and attach a file.
Additional: The link in this SO post appears to have been changed and no longer points to the intended page, but now points to the overall documentation for the REST API.
Currently, I believe the process should be:
Get release details
Get test run id
Get test case result id
Create test result attachment
The primary problem is getting the test run id and test case result id from the release information.
I guess I'm a bit late with this, but still.
You are right about the process. Getting Test run ID is possible via accessing logs of corresponding task inside the release. Here's the needed endpoint:
https://{organizationName}.vsrm.visualstudio.com/{projectName}/_apis/release/releases/{releaseID}/environments/{stageID}/deployPhases/{deployPhaseID}/tasks/{taskId}/logs
Please note that test run ID and test IDs will only be available after the test run task is finished.
I'd recommend getting release ID, stage ID and deployment phase ID directly from the release by accessing default variables provided by azure devops (e.g. $(Release.ReleaseId), other ones are easily googled) rather than fetching via API and matching by name, cause it takes time and does not return all releases, only 100 first or smth like that.
After this, you need to get TaskID. I found it possible and applicable looking for that by Task Name. Just fetch the release by it's ID via API and look for task which matches needed name using this endpoint:
https://{organizationName}.vsrm.visualstudio.com/{projectName}/_apis/release/releases/{releaseId}?api-version=5.0
Going through all the deploySteps, deployPhases, deployJobs to get the task name is a bit cumbersome, but possible (I used LINQ).
After getting these 4 base IDs, you are now able to get logs of the Run tests task. In received log I have used a regex to extract test run ID. Then, having test run ID, you can grab the list of test run results:
https://{organizationName}.visualstudio.com/{projectName}/_apis/test/runs/{testRunId}/results
To attach some files to a test, you will need this test's AzDo ID. How can you get it? Well, I can think of mapping the tests by their names (you will need to store a list of those beforehand) and then looping through fetched test results and the stored list. After a match is found, get the respective id, and attach anything you want:
https://{organizationName}.visualstudio.com/{projectName}/_apistest/Runs/{testRunId}/Results/{testId}/attachments?api-version=6.1-preview.1
I need to know how to import user stories for the project I am working on and filter those user stories using specific releases that some of them connected to
Actually I need something using the url to fitch this data like :
https://rally1.rallydev.com/slm/webservice/v3.0/artifact?query=((Release.Name=.............))=&fetch=true
but it is not filtering the data using the release name
also If I can modify this one to get the data that will be fine :
https://rally1.rallydev.com/slm/webservice/v3.0/hierarchicalrequirement/?fetch=Release,Tasks,FormattedID,Name,Owner,State&start=1&pagesize=200&pretty=true
Per WS API object model, there is no Release attribute on Artifact.
Use hierarchicalrequirement instead of artifact:
https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?query=(Release.Name%20%3D%20%22ReleaseABC%22)&fetch=FormattedID,ScheduleState&pagesize=200
Since you are fetching Tasks: as long as you are interested only in the reference to the collection and the count it is sufficient. If you want to hydrate the collection a separate request is needed. In this example we traverse WorkProduct.ObjectID:
https://rally1.rallydev.com/slm/webservice/v2.0/task?query=(WorkProduct.ObjectID%20%3D%12345)&fetch=State,ToDo,Estimate&pagesize=200