Giter Site home page Giter Site logo

azure-jira-update's People

Contributors

booyaa avatar haodeon avatar mwheeler-ep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-jira-update's Issues

Error: Associations must provide at least one value.

Output from DevOps

2021-11-16T23:09:32.3549810Z ##[section]Starting: Update JIRA status
2021-11-16T23:09:32.3560493Z ==============================================================================
2021-11-16T23:09:32.3561398Z Task         : PowerShell
2021-11-16T23:09:32.3562156Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2021-11-16T23:09:32.3563062Z Version      : 2.194.0
2021-11-16T23:09:32.3563699Z Author       : Microsoft Corporation
2021-11-16T23:09:32.3564531Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2021-11-16T23:09:32.3565420Z ==============================================================================
2021-11-16T23:09:32.4938693Z Generating script.
2021-11-16T23:09:32.4980409Z ========================== Starting Command Output ===========================
2021-11-16T23:09:32.5001748Z [command]/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/2b1d2e8b-b13a-45f1-8c0c-b08571eae222.ps1'
2021-11-16T23:09:33.2519096Z VERBOSE: Exporting function 'Add-JiraDeploymentInformation'.
2021-11-16T23:09:33.2521368Z VERBOSE: Exporting function 'Update-AzureDeploymentInformation'.
2021-11-16T23:09:34.8173089Z [Deployment Reponse] {
2021-11-16T23:09:34.8174818Z   "acceptedDeployments": [],
2021-11-16T23:09:34.8175809Z   "rejectedDeployments": [
2021-11-16T23:09:34.8176668Z     {
2021-11-16T23:09:34.8177481Z       "key": {
2021-11-16T23:09:34.8178345Z         "pipelineId": "53",
2021-11-16T23:09:34.8179235Z         "environmentId": "19",
2021-11-16T23:09:34.8180180Z         "deploymentSequenceNumber": 1637104174
2021-11-16T23:09:34.8181106Z       },
2021-11-16T23:09:34.8181931Z       "errors": [
2021-11-16T23:09:34.8182930Z         {
2021-11-16T23:09:34.8183959Z           "message": "Associations must provide at least one value."
2021-11-16T23:09:34.8184965Z         }
2021-11-16T23:09:34.8185767Z       ]
2021-11-16T23:09:34.8186556Z     }
2021-11-16T23:09:34.8187331Z   ],
2021-11-16T23:09:34.8188166Z   "unknownIssueKeys": [],
2021-11-16T23:09:34.8189072Z   "unknownAssociations": []
2021-11-16T23:09:34.8189902Z }
2021-11-16T23:09:34.8270906Z 
2021-11-16T23:09:34.8307083Z acceptedDeployments rejectedDeployments               unknownIssueKeys unknownA
2021-11-16T23:09:34.8316425Z                                                                        ssociati
2021-11-16T23:09:34.8317823Z                                                                        ons
2021-11-16T23:09:34.8319517Z ------------------- -------------------               ---------------- --------
2021-11-16T23:09:34.8320674Z {}                  {@{key=; errors=System.Object[]}} {}               {}
2021-11-16T23:09:34.8327720Z 
2021-11-16T23:09:34.9076348Z ##[section]Finishing: Update JIRA status

Steps to reproduce

This is primarily to help others who need to access the internal (private) functions in this excellent plugin.

Usage

  • Define the following environment variables:
    • SYSTEM_TOKEN - use your DevOps personal access token
    • SYSTEM_COLLECTIONURI - usually https://dev.azure.com/<Organization Name>/
    • SYSTEM_TEAMPROJECT - Project name
    • BUILD_BUILDID - Pipeline (run) build Id (any "release" branch pipeline run to see the problem)
  • Run script below
$DebugPreference="Continue"

$Features = Import-Module (Join-Path ".." "azure-jira-update" "EP.PowerShell.JiraDeployInfo") -PassThru # Allows us to access the private functions in this module

$SystemAccessToken = $env:SYSTEM_TOKEN # can use your Personal Access Token
$AzureChangeUrl = "$env:SYSTEM_COLLECTIONURI/$env:SYSTEM_TEAMPROJECT/_traceability/runview/changes?currentRunId=$($env:BUILD_BUILDID)&__rt=fps"

$jiraIds = @()
$jiraIds += ( & $Features `
                { 
                        param($SystemAccessToken, $AzureChangeUrl) 
                        Get-JiraIDsFromAzureChanges -SystemAccessToken $SystemAccessToken -AzureChangeUrl $AzureChangeUrl 
                } `
                -SystemAccessToken $SystemAccessToken -AzureChangeUrl $AzureChangeUrl )
$jiraIds

Useful docs

Notes

  • Deploys to the "Developement" environment are fine, these types of deploys occur when code is merged to the "main" branch
  • Deploys to the "Staging" and "Production" environment exhibit this error, these types of deploys occur when code a "releases" branch is created, these are branched off "main". Examples: "releases/1.2.3".

I'm going to see if I can test the PowerShell scripts locally using the build values from a previous pipeline run. Any pointers would be appreciated.

Feature: Retrieve JiraIDs from custom field in linked Work Items

First up. This is a life saver, and would be well worth publishing on the Devops Marketplace.

We use a sync tool which adds the Jira ID into a custom field on the Work Item, and then we reference the work item on a Pull Request so it is included as a linked item on the build/release.

It would be amazing if this plugin could optionally take the Jira ID from this field instead of only scanning the ChangeSet messages.

Is this something that you would be interested in adding? If not I might take a stab at it.

[Question] Using all this with Jira + Bitbucket

Hi,

so I did my initial test with the scripts, and looks really nice. Now I was about to push this to my pipelines just to see it in action. But I think I have a problem here (like quite some others). And maybe you have an idea how to resolve that.

So from my understanding looking at the script you ask the release pipeline for the changes, such that you can extract the Issue Numbers....the thing is: using Bitbucket (Cloud) is not capable to transport that information into Azure. SO checking for Issues, or Commits, it is actually always empty.
image

Any Idea how to get that information via an alternative way?!

so we have Jira ABC-123-> Bitbucket [ABC-123_BanchName,CommitMsg: Ref_ABC-123] -> DevOps Ppielines (PR,CI) -> Release.

Or do I do something wrong with DevOps that it looses the Issues?
Any Ideas is welcome :)

Bug: Linked Deployments do not correctly update

When using your example of the Pending > InProgress > Successful/Failed as part of a single deploy task, it is incorrectly creating multiple separate deployments, rather than changing the status of the existing one.

I checked the Jira docs and can see that a new deployment will be created based on a unique combination of pipelineId, environmentId and deploymentSequenceNumber.
https://developer.atlassian.com/cloud/jira/software/rest/api-group-deployments/#api-group-deployments

This line causes the issue. I would suggest replacing the datetime with the buildid.

deploymentSequenceNumber = [Int](Get-Date -UFormat "%s");

Thanks,

Basil

The Deployment does not have an associated Jira issue key goes in error

We have encountered a persistent error while running Add-JiraDeploymentInformation.ps1.
When executing the integration without an associated issue key in Jira, an error occurs. The error message received is as follows:

Invoke-RestMethod: /agent/_work/23/s/EP.PowerShell.JiraDeployInfo/Public/Add-JiraDeploymentInformation.ps1:181
Line |
181 | … $response = Invoke-RestMethod -uri "https://api.atlassian.com/jira/de
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| [{"message":"Associations must provide at least one value."}]

It appears that the issue stems from the Jira API, which no longer accepts association properties without a value.

image

Cannot convert value "1648551970,87108" to type "System.Int32". Error: "Input string was not in a correct format."

Hi ! I had this issue:
Cannot convert value "1648551970,87108" to type "System.Int32". Error: "Input string was not in a correct format."

when calling Add-JiraDeploymentInformation in a local powershell session.

turned out to be this line in the code:
updateSequenceNumber = (Get-Date -UFormat "%s");
I changed it to:
updateSequenceNumber = [math]::Round((Get-Date -UFormat "%s"));

not sure if this is a local setting that makes it that strange none int number.
Also in term of the readme that says " you can call this locally" - there is also
deploymentSequenceNumber = [Int]($env:BUILD_BUILDID);
that actually is a pipeline parameter and should look different :)

Using Win10, Powershell 5.1

Apart from that! So happy you made this! So sad that MS didn't manage to integrate with Jira AND Bitbucket correctly with their extensions.

Errors not being handled correctly

Output from the task

Starting: Update JIRA status
==============================================================================
Task         : PowerShell
Description  : Run a PowerShell script on Linux, macOS, or Windows
Version      : 2.194.0
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/home/vsts/work/_temp/c8c03347-497e-4f0b-b5fa-9d587c92c8dc.ps1'
VERBOSE: Exporting function 'Add-JiraDeploymentInformation'.
VERBOSE: Exporting function 'Update-AzureDeploymentInformation'.

acceptedDeployments rejectedDeployments               unknownIssueKeys unknownA
                                                                       ssociati
                                                                       ons
------------------- -------------------               ---------------- --------
{}                  {@{key=; errors=System.Object[]}} {}               {}

Finishing: Update JIRA status

Background info about our pipeline setup

  • Using multi-stage, one stage per environment (Development, Staging, Production, etc)
  • Using multiple deploy jobs per stage
    • API
    • UI
    • Automated test suites
  • For each deploy job we use the task to update Jira with the deployment status of 'InProgress' (if successful) until we reach the last deploy job where we set the status as 'Successful' or 'Failed'

Please let me know if you need any info.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.