CircleCI-Public / jira-connect-orb

Display the status of CircleCI workflows and deployments in Jira!
https://circleci.com/orbs/registry/orb/circleci/jira
MIT License
25 stars 27 forks source link

deployment job_type throws an "ERROR: unknown association" error message. #63

Closed anairamzap-mobomo closed 1 year ago

anairamzap-mobomo commented 3 years ago

Orb version

1.3.1

What happened

job_type deployment throws a ERROR: unknown association error.

Example redacted output for a deployment workflow:

"github-username"
This job is passing, however another job in workflow is success
Update Jira with status: successful for 63
Results from Jira: 
ERROR: unknown association
{
  "acceptedDeployments": [
    {
      "pipelineId": "repo-name",
      "environmentId": "ce36f16f-9b7f-4e36-8bb4-0262ca0a7e6f-Deploy to Dev",
      "deploymentSequenceNumber": 63
    }
  ],
  "rejectedDeployments": [],
  "unknownIssueKeys": [],
  "unknownAssociations": [
    {
      "associationType": "serviceIdOrKeys",
      "values": [
        ""
      ]
    }
  ]
}

CircleCI received exit code 0

Oddly enough, the deployment is not rejected, and the final exit code is 0 (CircleCI received exit code 0)

Expected behavior

Both build AND deployment job types don't throw errors? Or if this mentioned error is more like a warning (what I'm assuming since the exit code is 0 and the deployment doesn't get rejected) it should be outputted as a Warning or Info message.

Config yaml

version: 2.1
orbs:
  jira: circleci/jira@1.3.1

jobs:
  build-and-deploy-jira:
    docker:
      - image: mobomo/drupalstand-ci:0.1.4
    steps:
      - checkout
      - run: echo "Holu :)"

workflows:
  version: 2

  commit:
    jobs:
      - test:
          post-steps:
            - jira/notify # default "build" job_type it shows no errors.

# Deployment for testing.
  manual-deploy:
    jobs:
      - approve-dev-deployment:
          type: approval
          filters:
            branches:
              only: 
                - develop
      - build-and-deploy-jira:
          name: Deploy to Dev
          post-steps:
            - jira/notify:
                environment_type: development
                job_type: deployment
          requires:
            - approve-dev-deployment

More details

/tmp/jira-status.json

{
  "deployments": [
    {
      "schemaVersion": "1.0",
      "pipeline": {
        "id": "repo-name",
        "displayName": "#63 repo-name",
        "url": "https://circleci.com/workflow-run/ce36f16f-9b7f-4e36-8bb4-0262ca0a7e6f"
      },
      "deploymentSequenceNumber": "63",
      "updateSequenceNumber": "1614813995",
      "displayName": "#63  repo-name - Deploy to Dev",
      "description": "repo-name #63 Deploy to Dev Deploy to Dev",
      "url": "https://circleci.com/gh/username/repo-name/91",
      "state": "successful",
      "lastUpdated": "2021-03-03T23:26:35+00:00",
      "associations": [
        {
          "associationType": "issueKeys",
          "values": [
            "ABC-1234",
            "ABC-1234"
          ]
        },
        {
          "associationType": "serviceIdOrKeys",
          "values": [
            ""
          ]
        }
      ],
      "environment": {
        "id": "ce36f16f-9b7f-4e36-8bb4-0262ca0a7e6f-Deploy to Dev",
        "displayName": "Deploy to Dev",
        "type": "development"
      }
    }
  ]
}

/tmp/curl_response.txt

{
  "acceptedDeployments": [
    {
      "pipelineId": "repo-name",
      "environmentId": "ce36f16f-9b7f-4e36-8bb4-0262ca0a7e6f-Deploy to Dev",
      "deploymentSequenceNumber": 63
    }
  ],
  "rejectedDeployments": [],
  "unknownIssueKeys": [],
  "unknownAssociations": [
    {
      "associationType": "serviceIdOrKeys",
      "values": [
        ""
      ]
    }
  ]
}
$ cat project/circleci-orb-jira.status
JIRA_BUILD_STATUS="successful"

So... what I guess I'm trying to clarify is if that "unknown association" error is actually an error preventing something in the Orb functionality to work, OR if we can ignore it and probably best to output it as Info message.

Thanks!

m

gmemstr commented 3 years ago

Taking a look at this

gmemstr commented 3 years ago

@anairamzap-mobomo Quick question on this - when the message is shown, is there still an update within the Jira ticket that reflects the data sent from the job? I don't notice anything wrong with the payloads, but I do have a faint memory of possibly experiencing this myself while working on #61.

anairamzap-mobomo commented 3 years ago

Hi,

when the message is shown, is there still an update within the Jira ticket that reflects the data sent from the job?

Yes, that's why I suspect that this is not an error, but just a warning? For example:

"repo-user"
This job is passing, however another job in workflow is on_hold
Update Jira with status: successful for 116
Results from Jira: 
ERROR: unknown association
{
  "acceptedDeployments": [
    {
      "pipelineId": "repo-name",
      "environmentId": "8df4febd-490d-4118-82ec-bcd61fcc4d10-Deploy to QA",
      "deploymentSequenceNumber": 116
    }
  ],
  "rejectedDeployments": [],
  "unknownIssueKeys": [],
  "unknownAssociations": [
    {
      "associationType": "serviceIdOrKeys",
      "values": [
        ""
      ]
    }
  ]
}

CircleCI received exit code 0

And on Jira: image

stanma commented 3 years ago

In our case the same issue but when you're doing a buld/deployment with a git tag. Seems like this orb checks only branches (or CIRCLE_BRANCH env variable) and ignores tags (we include jira ticket number in it).

Is there is a way to make it work?

KyleTryon commented 3 years ago

Hello folks, 

Could anyone experiencing this issue provide more information about their usage?

The Issue ID must be located in either the branch name or the commit message (subject). We are looking into feedback there may be an edge-case related to tagged commits that experience this issue.

We have just tested the integration and did not replicate the issue. This has us thinking the issue may be around a bad regex pattern for the issue IDs or possibly the issue IDs not being picked up for another reason we are hoping to discover.

anairamzap-mobomo commented 3 years ago

@KyleTryon we are adding more details regarding this issue in https://github.com/CircleCI-Public/jira-connect-orb/pull/61#issuecomment-881492255

mjallday commented 1 year ago

I have been able to reproduce this issue I believe.

The issue appears to be the empty string for serviceIdOrKeys

        {
          "associationType": "serviceIdOrKeys",
          "values": [
             ""
          ]
        }

Results in the response

{
  "unknownIssueKeys": [],
  "unknownAssociations": [
    {
      "values": [
        ""
      ],
      "associationType": "serviceIdOrKeys"
    }
  ],
  "acceptedDeployments": [
    {
      "pipelineId": "vgs-gitops",
      "environmentId": "0c0a1dd6-6251-4aed-80a1-572b412c599d-dev",
      "deploymentSequenceNumber": 10085
    }
  ],
  "rejectedDeployments": []
}

When I alter this payload (manually via ssh on the job)

        {
          "associationType": "serviceIdOrKeys",
          "values": [
          ]
        }

Results in the response

{
  "unknownIssueKeys": [],
  "acceptedDeployments": [
    {
      "pipelineId": "vgs-gitops",
      "environmentId": "0c0a1dd6-6251-4aed-80a1-572b412c599d-dev",
      "deploymentSequenceNumber": 10085
    }
  ],
  "rejectedDeployments": []
}

The error goes away. I believe if the source is changed to not pass the empty string it will resolve the issue.

mjallday commented 1 year ago

In our case the same issue but when you're doing a buld/deployment with a git tag. Seems like this orb checks only branches (or CIRCLE_BRANCH env variable) and ignores tags (we include jira ticket number in it).

Seems like extending this plugin to fetch it from the commit associated to the tag would be the simplest way. We have this issue too and our tags do not include the jira ticket info but the commit it's associated to does.

git rev-list -n 1 $TAG would give the commit message according to https://stackoverflow.com/a/1862542/17977795

gailmiller-lysn commented 1 year ago

I have a slightly different use case. We PR branches (with jira ticket names) to a "dev" branch and test in there, All good. Then we merge "dev" to a "staging" with one PR. I get this error every time. I have tried adding the Jira ticket names in the comment, the description and this time even the PR Name (which is not sustainable going forward).

I have noted that its not linking the tickets that moved from one org to another (we moved the repo) which I can accept as an edge case :)

If you could definitely pull the tickets from the commits (which would look at the branch names in the PRs we have and then do all this stuff automatically) that would be a massive improvement on this orb.

KyleTryon commented 1 year ago

Hello Friends 👋

The day has finally come 🎉 ! As we have alluded to in a few spots in this repository, we have been working on a new integration for Jira with CircleCI to replace this outdated orb which has historically been difficult for us to update. Today we are excited to announce Jira Integration V2 is finally LIVE!

New Docs: https://circleci.com/docs/jira-plugin/ Orb v2:

Atlassian Forge App: https://github.com/CircleCI-Public/circleci-for-jira

Key Features

What to know