Hello! I wonder how I can integrate Jenkins and Jita ( Deployment info).
I successfully did everything from this tutorial: https://support.atlassian.com/jira-cloud-administration/docs/integrate-with-jenkins/
But I can't find the following parameters: environmentId, environmentName, and environmentType. Where I can find them?
Thanks in advance!
While I'm not an expert in this particular integration, I believe I found the answer here. Check out the Readme.md in https://github.com/jenkinsci/atlassian-jira-software-cloud-plugin it indicates that
we use a post step to send deployment data to Jira and the relevant issues. Here, the environmentId, environmentName, and environmentType need to be set to whatever you want to appear in Jira.
So those values are not expected to be found in Jira, but rather these are something that you supply about the Jenkins environment that you want to appear within Jira.
I found some more info on these fields over in https://www.jenkins.io/doc/pipeline/steps/atlassian-jira-software-cloud/ which indicates these are optional fields to begin with.
I hope this helps.
Andy
Hi @Nikita Sevostyanov @Andy Heinzer
I have done the implementation using below apis to send deployment info on jira using post request. But facing issues while assigning env variable for environmentId parameter in post request. Getting this error.
"acceptedDeployments": [ ], "rejectedDeployments": [ { "key": { "deploymentSequenceNumber": 35 }, "errors": [ { "message": "Invalid JSON: \u0027environment\u0027 is invalid. Must be of type EnvironmentDetails." } ] } ]
https://developer.atlassian.com/cloud/jira/software/rest/api-group-deployments/#api-rest-deployments-0-1-bulk-post
Thanks in advance, any help 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 @Nikita Sevostyanov
The API simply needs an environment that you can specific within your request to the API.
I left out the other bits but your request needs to include the following:
{
"deployments": [
{
...
"environment": {
"id": "unique-env-id",
"displayName": "env-name",
"type": "env-type"
},
...
}
]
}
Simple replace `unique-env-id` with a unique Id of the environment. In my app I use this line to generate an Id based on the name of the environment
UUID.nameUUIDFromBytes(environmentName.getBytes(StandardCharsets.UTF_8)).toString()
Replace `env-name` with a human readable name of the environment.
And finally replace `env-type` with one of the following possible values unmapped
, development
, testing
, staging
, production
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 inputs @Mark Rekveld - Marvelution
But I am using powershell script below and unfamilier with
UUID.nameUUIDFromBytes(environmentName.getBytes(StandardCharsets.UTF_8)).toString()
this.
can you please explain in detail how and where should I run above line so I can get environment parameters in that format.
Here is my powershell script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, that line is for Java.
The objective of the line to generate an id based on the input. If the input is gives twice without changing it then the generated id should be the same.
You can also use a checksum like MD5.
But if you already have an unique id that is available in the context of the build, then you can use that as well.
I have never worked with powershell so am not sure if it has the capability to generate a unique string based on another string.
If all else fails, you can always opt to manually specify an id. Especially if the environment is only used with one build, then why generate if you can specify.
Cheers,
Mark
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.
Hi @Mark Rekveld - Marvelution
what do you think about this ?
"errors": [ { "message": "Invalid JSON: \u0027associations\u0027 is invalid. Must be of type Array." } ]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Pranav Lonsane that is most likely that the environment object in the json is not formatted correctly, or has missing, invalid values.
Can you print the json send to the console output so you can check?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes printed it is giving
System.Collections.Hashtable
so do I need to convert it into hashtable ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can powershell convert the hashtable to valid json?
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.
Can you share the json your powershell generates before sending it to the API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes here it is
{
"associationType": "issueIdOrKeys",
"values[]": "KAN-6"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is way less that is needed, far more fields are required.
Are you sure this is the complete JSON generated by the powershell?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, have provided you json representaion of only associations field.
And these are the minimum parameters have provided.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The association field is formatted incorrectly it needs to be as follows:
{
"associationType": "issueIdOrKeys",
"values": ["KAN-6"]
}
If the script is making this 'error' then it may be inserting errors else where to.
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.