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

jq: error (at <stdin>:549): null (null) cannot be matched, as it is not a string #35

Closed aspcanada closed 4 years ago

aspcanada commented 4 years ago

Orb version

1.1.2

What happened

When building a git tag in Circle, there is no branch. In the /tmp/job_info.json, the branch key is null.

Expected behavior

orb should fail gracefully upon not finding any ISSUE_KEYS

aspcanada commented 4 years ago

I have a fix for this...

Simply replace .branch > if .branch then .branch else "" end on line 73 of notify.yml

src/commands/notify.yml:73 ISSUE_KEYS=$(cat /tmp/job_info.json | jq '[.all_commit_details[].subject | scan("(<<parameters.issue_regexp>>)") | .[] ] + [.all_commit_details[].branch | scan("(<<parameters.issue_regexp>>)") | .[] ] + [if .branch then .branch else "" end | scan("(<<parameters.issue_regexp>>)") | .[] ]')

aspcanada commented 4 years ago

@eddiewebb, I can open a PR is you'd like...

lokst commented 4 years ago

@aspcanada It would be wonderful if you could open a PR for this, thank you! (cc @KyleTryon @eddiewebb )

KyleTryon commented 4 years ago

Hey all, taking a look today. @aspcanada thank you for the assistance. We will update this by end of day and report back here.

randywallace commented 4 years ago

I ran into this today as well; one thing I observed in troubleshooting this, is that, as this is a tag, there is no commit/branch/pr information to derive an Issue ID from (from the API response); as such, if the vcs_tag is populated in the job json response, why not just skip pinging Jira at all and exit early with something that exits 0 and mentions as much