Hello,
We are currently submitting our builds and deployments information from Jenkins to the JIRA Cloud instance via the corresponding API.
In the documentation https://developer.atlassian.com/cloud/jira/software/rest/api-group-deployments it states that
Deployments are identified by the combination of pipelineId
, environmentId
and deploymentSequenceNumber
In our case, for each deployment in the same environment pipelineId and environmentId stay the same and the deploymentSequenceNumber is an incremental int(Jenkins build number). However the ticket deployments panel does not show multiple deployments separately and only shows the latest one, which gets updated (new name, new modified time).
The general Deployments panel shows the history of all deployments correcly.
I can't find any information if this is by design or am i doing something wrong in submitted metadata?
I would expect the ticket view to show all the deployments (albeit on the same environment and the same pipeline) to be shown.
Can you shed some light on this for me please?
Hello @Evgenios Soroka ,
Before going any further, can you kindly let us know whether you are using the open source integration with Jenkins built by Atlassian (links below) or if you are using a custom integration you have built yourself?
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your quick reply @Evgenios Soroka !
I have contacted the dev team responsible for this and I been told that your understanding is correct:
deploymentSequenceNumber makes a deployment unique in the timeline of a pipelineId + environmentId.
it's possible to perform an update when the updateSequenceNumber is incremented.
the development panel always presents the latest deployment (latest deploymentSequenceNumber) of a single pipelineId + environmentId. This is because the most important information for the end user is to know which is the state of the latest deployment, as we do for builds as well.
Kindly let me know if this helps or if you have further questions on this topic.
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are very welcome @Evgenios Soroka , have a nice weekend!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Evgenios Soroka @Dario B
I am doing the same means submitting the deployment information on jira using jenkins powershell script with https://developer.atlassian.com/cloud/jira/software/rest/api-group-deployments/#api-rest-deployments-0-1-bulk-post this api.
But getting following error
"acceptedDeployments": [ ], "rejectedDeployments": [ { "key": { "deploymentSequenceNumber": 35 }, "errors": [ { "message": "Invalid JSON: \u0027environment\u0027 is invalid. Must be of type EnvironmentDetails." } ] } ]
Sharing my powershell script here
# Set the SecurityProtocol
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$tokenUrl = "https://api.atlassian.com/oauth/token"
$client_id = "value_of_client_id"
$client_secret = "value_of_client_secret"
$body = @{
audience = "api.atlassian.com"
grant_type = "client_credentials"
client_id = $client_id
client_secret = $client_secret
}
$response = Invoke-RestMethod -Method Post -Uri $tokenUrl -ContentType "application/json" -Body ($body | ConvertTo-Json)
$access_token = $response.access_token
$expires_in = $response.expires_in
$token_type = $response.token_type
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$uri = 'https://api.atlassian.com/jira/deployments/0.1/cloud/value_of_cloud_id/bulk'
$headers = @{
"Accept" = "application/json"
"Content-Type" = "application/json"
"Authorization" = "Bearer $access_token"
"Cookie" = "atlassian.xsrf.token=f636d78bb3157739b8d67f168e23fac87a2ec469_lin"
}
$objForRemote = @{
BUILD_NUMBER = $env:BUILD_NUMBER
EXECUTOR_NUMBER = $env:EXECUTOR_NUMBER
JOB_NAME = $env:JOB_NAME
BUILD_URL = $env:BUILD_URL
BUILD_STATUS = $env:BUILD_STATUS
BUILD_TIMESTAMP = $env:BUILD_TIMESTAMP
BUILD_ID = $env:BUILD_ID
BUILD_TargetEnvironmentType = $env:BUILD_TargetEnvironmentType
BUILD_TargetEnvironment = $env:BUILD_TargetEnvironment
}
$environment = @{
id = "8ec94d72-a4fc-4ac0-b31d-c5a595f373ba"
displayName = $objForRemote.BUILD_TargetEnvironment
type = $objForRemote.BUILD_TargetEnvironmentType
}
$data = @{
deployments = @(
@{
deploymentSequenceNumber = $objForRemote.BUILD_NUMBER
updateSequenceNumber = $objForRemote.EXECUTOR_NUMBER
associations = @(
@{
associationType = 'issueIdOrKeys'
values = @('KAN-6')
}
)
displayName = $objForRemote.JOB_NAME
url = $objForRemote.BUILD_URL
description = $objForRemote.BUILD_STATUS
lastUpdated = $objForRemote.BUILD_TIMESTAMP
state = 'successful'
pipeline = @{
id = $objForRemote.BUILD_ID
displayName = $objForRemote.JOB_NAME
url = $objForRemote.BUILD_URL
}
environment = $environment
}
)
}
$jsonData = $data | ConvertTo-Json
$response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $jsonData
$response | ConvertTo-Json -Depth 9
# Check if the response contains an "errors" field
if ($response -is [System.Array]) {
Write-Host "Errors found:"
$response.errors
} else {
$acceptedDeployments = $response.acceptedDeployments
$rejectedDeployments = $response.rejectedDeployments
Write-Host "Accepted Deployments:"
$acceptedDeployments
Write-Host "Rejected Deployments:"
$rejectedDeployments
}
Any suggestions on this would be appreciable
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Pranav Lonsane According to the error message there is a problem with the provided payload:
"Invalid JSON: \u0027environment\u0027 is invalid. Must be of type EnvironmentDetails."
You may want to print the created JSON payload and make sure it's correct (you can try to send the same payload using curl or POSTMAN, etc)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.