Я пытаюсь создать выпуск, используя DevOps REST API . Определение правильное, так как я могу создать его вручную, но вызов REST завершается неудачно со следующим журналом:
##[Error 1]
Exception Message: 235 is not a valid Build ID or BuildNumber. Make sure that the build succeeded or partially succeeded and is not deleted. (type ReleaseManagementExternalServiceException)
Exception Stack Trace: at Microsoft.VisualStudio.Services.ReleaseManagement.Artifact.Extensions.Build.BuildArtifact.GetBuildInternal(IVssRequestContext requestContext, Guid projectId, Int32 buildId) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\ArtifactType\Build\BuildArtifact.cs:line 3606
at Microsoft.VisualStudio.Services.ReleaseManagement.Artifact.Extensions.Build.BuildArtifact.GetBuild(IVssRequestContext requestContext, Guid projectId, Int32 buildId) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\ArtifactType\Build\BuildArtifact.cs:line 391
at Microsoft.VisualStudio.Services.ReleaseManagement.Artifact.Extensions.Build.BuildArtifact.GetArtifactConfigurationVariables(IVssRequestContext context, ArtifactSource artifactSource) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\ArtifactType\Build\BuildArtifact.cs:line 2744
at Microsoft.VisualStudio.Services.ReleaseManagement.Server.Processors.DeployPhaseRunner.GetArtifactVariables(Release release, IVssRequestContext requestContext) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\Server\Processors\DeployPhaseRunner.cs:line 379
at Microsoft.VisualStudio.Services.ReleaseManagement.Server.Processors.DeployPhaseRunner.GetMergedReleaseVariables(Release release, ReleaseEnvironment releaseEnvironment, ReleaseEnvironmentSnapshotDelta deploymentDelta, Boolean includeArtifactVariables) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\Server\Processors\DeployPhaseRunner.cs:line 582
at Microsoft.VisualStudio.Services.ReleaseManagement.Server.Processors.DeployPhaseRunner.GetAutomationEngineInput(Release release, ReleaseEnvironment releaseEnvironment, ReleaseEnvironmentStep step, Int32 trialNumber, DeployPhaseSnapshot snapshotToProcess, ReleaseEnvironmentSnapshotDelta deploymentDelta) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\Server\Processors\DeployPhaseRunner.cs:line 287
at Microsoft.VisualStudio.Services.ReleaseManagement.Server.Processors.DeployPhaseRunner.Run(Release release, ReleaseEnvironment releaseEnvironment, ReleaseEnvironmentStep deployStep, DeployPhaseSnapshot snapshotToProcess) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\Server\Processors\DeployPhaseRunner.cs:line 190
Inner Exception Details:
Exception Message: The requested build 235 could not be found.
(type ReleaseManagementExternalServiceException)
Exception Stack Trace: at Microsoft.VisualStudio.Services.ReleaseManagement.Common.Extensions.TaskExtension.GetResult[T](Task`1 task, CancellationToken token) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\Common\Extensions\TaskExtension.cs:line 43
at Microsoft.VisualStudio.Services.ReleaseManagement.Artifact.Extensions.Build.BuildArtifact.GetBuildInternal(IVssRequestContext requestContext, Guid projectId, Int32 buildId) in D:\v2.0\P1\_work\7\s\ReleaseManagement\Service\ReleaseManagement2\ArtifactType\Build\BuildArtifact.cs:line 3600
Inner Exception Details:
Exception Message: The requested build 235 could not be found. (type BuildNotFoundException)
Exception Stack Trace: at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__53.MoveNext() in D:\v2.0\P1\_work\7\s\Vssf\Client\WebApi\VssHttpClientBase.cs:line 942
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__51.MoveNext() in D:\v2.0\P1\_work\7\s\Vssf\Client\WebApi\VssHttpClientBase.cs:line 883
--- End of stack
Это сценарий PowerShell, который я написал:
using namespace System
using namespace System.Text
$pat = '****************************************************'
$credentials = [Convert]::ToBase64String([Encoding]::ASCII.GetBytes(":$pat"))
$organization = 'myorg'
$project = 'My%20Project'
$definitionId = 71
$buildId = 235 # this is the wrong value
$uri = "https://vsrm.dev.azure.com/$organization/$project/_apis/release/releases?api-version=5.0"
$json = @"
{
"definitionId": $definitionId,
"description": "Sample Release",
"artifacts": [
{
"alias": "Source",
"instanceReference": {
"id": "$buildId",
"name": null
}
}
],
"isDraft": false,
"reason": "none",
"manualEnvironments": null
}
"@
$response = Invoke-RestMethod -Uri $uri -Method Post -ContentType 'application/json' -Body $json `
-Headers @{
Authorization = "Basic $credentials"
}
$response | ConvertTo-Json -Depth 100 | Out-File out.json
Я установил artifacts.instanceReference.id
в ID конвейера сборки. Я знаю, что это неправильно, но из документации я не смог понять, какое значение мне нужно установить для правильного создания новой версии.
Что именно это за значение? И где я могу получить его с помощью API REST DevOps?
Любая помощь будет очень признательна!
Giacomo SS