1. circleci/jira@2.2.0

circleci/jira@2.2.0

Certified
Sections
Connect your CircleCI pipelines to Jira. Define builds and deployments as config and automatically update Jira issues with the results of your pipelines.
Created: March 19, 2019Version Published: December 30, 2024Releases: 26
Org Usage:
713
Categories:

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: jira: circleci/jira@2.2.0

Use jira elements in your existing workflows and jobs.

Usage Examples

send_build_notification

Send build notifications to Jira as a part of your CI config. Add the notify command as the last step of your job. By default, the branch name will be used to identify the Jira issue. A 'JIRA_WEBHOOK_URL' environment variable must be provided.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 version: '2.1' orbs: jira: circleci/jira@2.0 node: circleci/node@5.1 jobs: build: executor: node/default steps: - checkout - node/install-packages - run: command: npm test name: Test app - jira/notify: pipeline_id: << pipeline.id >> pipeline_number: << pipeline.number >> workflows: build-workflow: jobs: - build: context: JIRA_WEBHOOK

send_pipelines_to_jira

Send pipeline job statuses to Jira as a part of your CI config. A 'JIRA_WEBHOOK_URL' environment variable must be provided.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 version: '2.1' orbs: jira: circleci/jira@2.0 node: circleci/node@5.1 jobs: build: executor: node/default steps: - checkout - node/install-packages - run: command: npm test name: Run tests - jira/notify: pipeline_id: << pipeline.id >> pipeline_number: << pipeline.number >> deploy: executor: node/default steps: - checkout - node/install-packages - run: command: npm run deploy name: Run Deployment - jira/notify: environment: staging environment_type: staging job_type: deployment pipeline_id: << pipeline.id >> pipeline_number: << pipeline.number >> service_id: 123456 workflows: main: jobs: - build: context: JIRA_WEBHOOK filters: tags: only: /.*/ - deploy: context: JIRA_WEBHOOK filters: branches: ignore: /.*/ tags: only: /^v.*/ requires: - build

Commands

notify

Send a notification to Jira for a build or deployment.

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
debug
Enable additional logging if you are running into issues. A log will be generated at '/tmp/circleci_jira.log'.
No
false
boolean
environment
For deployments. Indicates the name of target environment. By default the name of the CircleCI Job is used.
No
${CIRCLE_JOB}
string
environment_type
Indicates the category of target environment as defined by Atlassian
No
development
enum
ignore_errors
Ignore errors. Errors posting to Atlassian will not result in failed builds unless disabled.
No
true
boolean
issue_regexp
Override the default project key regexp if your project keys follow a different format. Your key must be in the [1] capture group.
No
([A-Z]{2,30}-[0-9]+)
string
job_type
Indicates if job should be treated as build or deployment in Jira dev panel. Note that Deployments require additional details.
No
build
enum
oidc_token
Customize the OpenID Connect token used to authenticate with Jira. This most often will not need to be changed.
No
${CIRCLE_OIDC_TOKEN_V2}
string
pipeline_id
Pass in the pipeline id via CircleCI pipeline parameters. This must be specified manually. Refer to usage example.
Yes
-
string
pipeline_number
Pass in the pipeline number via CircleCI pipeline parameters. This must be specified manually. Refer to usage example.
Yes
-
integer
service_id
Specify the JSD service ID for the project this notification targets. This will be sent with deployment notifications.
No
${JIRA_SERVICE_ID}
string
webhook_url
Get your webhook URL from the management panel in the CircleCI for Jira app in Atlassian.
No
${JIRA_WEBHOOK_URL}
string

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing version: 2.1 description: | Connect your CircleCI pipelines to Jira. Define builds and deployments as config and automatically update Jira issues with the results of your pipelines. display: home_url: https://circleci.com/docs/jira-plugin/ source_url: https://github.com/circleci-public/jira-orb commands: notify: description: | Send a notification to Jira for a build or deployment. parameters: debug: default: false description: Enable additional logging if you are running into issues. A log will be generated at '/tmp/circleci_jira.log'. type: boolean environment: default: ${CIRCLE_JOB} description: For deployments. Indicates the name of target environment. By default the name of the CircleCI Job is used. type: string environment_type: default: development description: Indicates the category of target environment as defined by Atlassian enum: - production - staging - testing - development - unmapped type: enum ignore_errors: default: true description: Ignore errors. Errors posting to Atlassian will not result in failed builds unless disabled. type: boolean issue_regexp: default: ([A-Z]{2,30}-[0-9]+) description: Override the default project key regexp if your project keys follow a different format. Your key must be in the [1] capture group. type: string job_type: default: build description: Indicates if job should be treated as build or deployment in Jira dev panel. Note that Deployments require additional details. enum: - build - deployment type: enum oidc_token: default: ${CIRCLE_OIDC_TOKEN_V2} description: Customize the OpenID Connect token used to authenticate with Jira. This most often will not need to be changed. type: string pipeline_id: description: Pass in the pipeline id via CircleCI pipeline parameters. This must be specified manually. Refer to usage example. type: string pipeline_number: description: Pass in the pipeline number via CircleCI pipeline parameters. This must be specified manually. Refer to usage example. type: integer service_id: default: ${JIRA_SERVICE_ID} description: Specify the JSD service ID for the project this notification targets. This will be sent with deployment notifications. type: string webhook_url: default: ${JIRA_WEBHOOK_URL} description: Get your webhook URL from the management panel in the CircleCI for Jira app in Atlassian. type: string steps: - run: command: | #!/bin/bash echo "${JOB_STATUS}" >/tmp/circleci_jira_status environment: JOB_STATUS: failed name: 'Jira - Detecting Job Status: Failed' when: on_fail - run: command: | #!/bin/bash echo "${JOB_STATUS}" >/tmp/circleci_jira_status environment: JOB_STATUS: successful name: 'Jira - Detecting Job Status: Successful' when: on_success - run: command: | #!/bin/bash # This script requires Bash v4+ or zsh. # MacOS on CircleCI ships with Bash v3.x as the default shell # This script determines which shell to execute the notify script in. if [[ "$(uname -s)" == "Darwin" ]]; then echo "Running in ZSH on MacOS" /bin/zsh -c "setopt KSH_ARRAYS BASH_REMATCH SHWORDSPLIT; $JIRA_SCRIPT_NOTIFY" else /bin/bash -c "$JIRA_SCRIPT_NOTIFY" fi environment: JIRA_BOOL_DEBUG: <<parameters.debug>> JIRA_BOOL_IGNORE_ERRORS: <<parameters.ignore_errors>> JIRA_SCRIPT_NOTIFY: | #!/bin/bash # create log file JIRA_LOGFILE=/tmp/circleci_jira.log touch $JIRA_LOGFILE # Ensure status file exists if [ ! -f "/tmp/circleci_jira_status" ]; then echo "Status file not found at /tmp/circleci_jira_status" exit 1 # Critical error, do not skip fi # Functions to create environment variables # Determine the VCS type getVCS() { REGEXP="com\/([A-Za-z]+)\/" if [[ $CIRCLE_BUILD_URL =~ $REGEXP ]]; then PROJECT_VCS="${BASH_REMATCH[1]}" else echo "Unable to determine VCS type" exit 1 # Critical error, do not skip fi } errorOut() { echo "Exiting..." STATUS=${1:-0} if [[ "$JIRA_BOOL_IGNORE_ERRORS" == "1" ]]; then STATUS=0 fi exit "$STATUS" } # Get the slug given the build url getSlug() { if [[ "$PROJECT_VCS" == "circleci" ]]; then REGEXP="com\/([A-Za-z]+\/.*)" if [[ $CIRCLE_BUILD_URL =~ $REGEXP ]]; then PROJECT_SLUG="${BASH_REMATCH[1]}" fi else REGEXP="com\/([A-Za-z]+\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\/" if [[ $CIRCLE_BUILD_URL =~ $REGEXP ]]; then PROJECT_SLUG="${BASH_REMATCH[1]}" fi fi if [[ ${#PROJECT_SLUG} -eq 0 ]]; then echo "Unable to determine project slug" exit 1 # Critical error, do not skip fi } # Accepts a string and returns an array of keys parseKeys() { local KEY_ARRAY=() while [[ "$1" =~ $JIRA_VAL_ISSUE_REGEXP ]]; do KEY_ARRAY+=("${BASH_REMATCH[1]}") # Remove the matched part from the string so we can continue matching the rest local rest="${1#*"${BASH_REMATCH[0]}"}" set -- "$rest" done echo "${KEY_ARRAY[@]}" } remove_duplicates() { declare -A seen # Declare UNIQUE_KEYS as a global variable UNIQUE_KEYS=() for value in "$@"; do # Splitting value into array by space, considering space-separated keys in a single string for single_value in $value; do TRIMMED_VALUE="$(echo -e "${single_value}" | tr -d '[:space:]')" # If the trimmed value has not been seen before, add it to the UNIQUE_KEYS array and mark it as seen if [[ ! -v seen["$TRIMMED_VALUE"] ]]; then UNIQUE_KEYS+=("$TRIMMED_VALUE") seen["$TRIMMED_VALUE"]=1 fi done done } # Sets the JIRA_ISSUE_KEYS or prints an error getIssueKeys() { local KEY_ARRAY=() # Parse keys from branch and commit message local BRANCH_KEYS BRANCH_KEYS="$(parseKeys "$CIRCLE_BRANCH")" local COMMIT_KEYS COMMIT_KEYS="$(parseKeys "$COMMIT_MESSAGE")" BODY_KEYS="$(parseKeys "$COMMIT_BODY")" log "GETTING TAG KEYS" local TAG_KEYS TAG_KEYS="$(getTagKeys)" # Check if the parsed keys are not empty before adding to the array. [[ -n "$BRANCH_KEYS" ]] && KEY_ARRAY+=("$BRANCH_KEYS") [[ -n "$COMMIT_KEYS" ]] && KEY_ARRAY+=("$COMMIT_KEYS") [[ -n "$BODY_KEYS" ]] && KEY_ARRAY+=("$BODY_KEYS") [[ -n "$TAG_KEYS" ]] && KEY_ARRAY+=("$TAG_KEYS") # Remove duplicates remove_duplicates "${KEY_ARRAY[@]}" KEY_ARRAY=("${UNIQUE_KEYS[@]}") # Exit if no keys found if [[ ${#KEY_ARRAY[@]} -eq 0 ]]; then local message="No issue keys found in branch, commit message, or tag" local dbgmessage=" Branch: $CIRCLE_BRANCH\n" dbgmessage+=" Commit: $COMMIT_MESSAGE\n" dbgmessage+=" Body: $COMMIT_BODY\n" dbgmessage+=" Tag: $(git tag --points-at HEAD -l --format='%(tag) %(subject)' )\n" echo "$message" echo -e "$dbgmessage" printf "\nSkipping Jira notification\n\n" exit 0 fi # Set the JIRA_ISSUE_KEYS variable to JSON array JIRA_ISSUE_KEYS=$(printf '%s\n' "${KEY_ARRAY[@]}" | jq -R . | jq -s .) echo "Issue keys found:" echo "$JIRA_ISSUE_KEYS" | jq -r '.[]' # Export JIRA_ISSUE_KEYS for use in other scripts or sessions export JIRA_ISSUE_KEYS } # Post the payload to the CircleCI for Jira Forge app postForge() { FORGE_PAYLOAD=$1 COUNT=${2:-1} echo "Posting payload to CircleCI for Jira Forge app" FORGE_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "${JIRA_VAL_JIRA_WEBHOOK_URL}" \ -H "Content-Type: application/json" \ -H "Authorization: ${JIRA_VAL_JIRA_OIDC_TOKEN}" \ -d "${FORGE_PAYLOAD}") HTTP_BODY=$(echo "$FORGE_RESPONSE" | sed -e '$d') HTTP_STATUS=$(echo "$FORGE_RESPONSE" | tail -n 1) MSG=$(printf "HTTP Status: %s\nHTTP Body: %s\n" "$HTTP_STATUS" "$HTTP_BODY") log "$MSG" # Check for errors if ! JIRA_ERRORS="$(echo "$HTTP_BODY" | jq -r '..|select(type == "object" and (has("errors") or has("error")))|(.errors // .error)')";then echo "Error parsing response" errorOut 1 fi if [[ "$HTTP_STATUS" -gt 299 || ${#JIRA_ERRORS} -gt 0 ]]; then printf "\nError posting payload to CircleCI for Jira Forge app\n" echo " HTTP Status: $HTTP_STATUS" echo " Errors:" echo "$JIRA_ERRORS" | jq '.' fi if [[ "$HTTP_STATUS" -gt 299 && "$HTTP_STATUS" -lt 399 ]] && [[ "$COUNT" -lt 5 ]]; then echo "Retrying... ($((COUNT + 1)))" sleep 3 postForge "$FORGE_PAYLOAD" "$((COUNT + 1))" elif [[ "$HTTP_STATUS" -gt 399 ]]; then errorOut 1 fi } # Verify any values that need to be present before continuing verifyVars() { MSG=$(printf "OIDC Token: %s\nWebhook URL: %s\nEnvironment: %s\n" "$JIRA_VAL_JIRA_OIDC_TOKEN" "$JIRA_VAL_JIRA_WEBHOOK_URL" "$JIRA_VAL_ENVIRONMENT") log "$MSG" if [[ -z "$JIRA_VAL_JIRA_OIDC_TOKEN" ]]; then echo "'oidc_token' parameter is required" exit 1 # Critical error, do not skip fi if ! [[ "$JIRA_VAL_JIRA_WEBHOOK_URL" =~ ^https:\/\/([a-zA-Z0-9.-]+\.[A-Za-z]{2,6})(:[0-9]{1,5})?(\/.*)?$ ]]; then echo " Please check the value of the 'webhook_url' parameter and ensure it contains a valid URL or a valid environment variable" echo " Value: $JIRA_VAL_JIRA_WEBHOOK_URL" exit 1 # Critical error, do not skip fi if [[ -z "$JIRA_VAL_ENVIRONMENT" ]]; then echo "'environment' parameter is required" echo " Value: $JIRA_VAL_ENVIRONMENT" exit 1 # Critical error, do not skip fi } log() { if [[ "$JIRA_DEBUG_ENABLE" == "true" ]]; then { echo "" echo "$1" echo "" } >>$JIRA_LOGFILE printf "\n #### DEBUG ####\n %s\n ###############\n\n" "$1" fi } getTags() { local TAG_ARRAY=() GIT_TAG=$(git tag --points-at HEAD) [[ -n "$GIT_TAG" ]] && TAG_ARRAY+=("$GIT_TAG") echo "${TAG_ARRAY[@]}" } getTagKeys() { local TAG_KEYS=() local TAGS TAGS="$(getTags)" for TAG in $TAGS; do local ANNOTATION ANNOTATION="$(git tag -l -n1 "$TAG")" [ -n "$ANNOTATION" ] || continue TAG_KEYS+=("$(parseKeys "$ANNOTATION")") done echo "${TAG_KEYS[@]}" } circleciCliCheck() { HAS_CIRCLECI_CLI=0 which circleci > circleci-location.log || HAS_CIRCLECI_CLI=$? if [[ "$HAS_CIRCLECI_CLI" != 0 ]]; then echo "CircleCI CLI not installed, unable to continue!" errorOut 1 else echo "CircleCI CLI installed at: $(cat circleci-location.log)" rm circleci-location.log fi } # Verify presence of circleci circleciCliCheck # Sanetize the input # JIRA_VAL_JOB_TYPE - Enum string value of 'build' or 'deploy' # JIRA_BOOL_DEBUG - 1 = true, 0 = false if [[ "$JIRA_BOOL_DEBUG" -eq 1 ]]; then JIRA_DEBUG_ENABLE="true" else JIRA_DEBUG_ENABLE="false" fi JIRA_LOG_LEVEL=$([ "$JIRA_DEBUG_ENABLE" = true ] && echo "log" || echo "error") JIRA_VAL_ENVIRONMENT=$(circleci env subst "${JIRA_VAL_ENVIRONMENT}") JIRA_VAL_ENVIRONMENT_TYPE=$(circleci env subst "${JIRA_VAL_ENVIRONMENT_TYPE}") JIRA_VAL_STATE_PATH=$(circleci env subst "${JIRA_VAL_STATE_PATH}") JIRA_VAL_SERVICE_ID=$(circleci env subst "${JIRA_VAL_SERVICE_ID}") JIRA_VAL_ISSUE_REGEXP=$(circleci env subst "${JIRA_VAL_ISSUE_REGEXP}") JIRA_VAL_JIRA_OIDC_TOKEN=$(circleci env subst "${JIRA_VAL_JIRA_OIDC_TOKEN}") JIRA_VAL_JIRA_WEBHOOK_URL=$(circleci env subst "${JIRA_VAL_JIRA_WEBHOOK_URL}") # Add the log parameter to the URL JIRA_VAL_JIRA_WEBHOOK_URL="${JIRA_VAL_JIRA_WEBHOOK_URL}?verbosity=${JIRA_LOG_LEVEL}" # JIRA_VAL_PIPELINE_ID - pipeline id # JIRA_VAL_PIPELINE_NUMBER - pipeline number TIME_EPOCH=$(date +%s) TIME_STAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z") # JIRA_DEBUG_TEST_COMMIT is only used in testing COMMIT_MESSAGE=$(git show -s --format='%s' "${JIRA_DEBUG_TEST_COMMIT:-$CIRCLE_SHA1}") COMMIT_BODY=$(git show -s --format='%b' "${JIRA_DEBUG_TEST_COMMIT:-$CIRCLE_SHA1}") JIRA_BUILD_STATUS=$(cat /tmp/circleci_jira_status) PROJECT_VCS="" PROJECT_SLUG="" JIRA_ISSUE_KEYS=() # Set in getIssueKeys # Built-ins - For reference # CIRCLE_BUILD_URL is the URL of the current build # CIRCLE_SHA1 is the commit hash of the current build # CIRCLE_BRANCH is the branch name of the current build # Set variables which require functions ## Variables are set directly rather than returned to improve error handling getVCS getSlug JIRA_PIPELINE_URL="https://app.circleci.com/pipelines/$PROJECT_SLUG/$JIRA_VAL_PIPELINE_NUMBER" # Export variables for use in envsubst export JIRA_VAL_ENVIRONMENT export JIRA_VAL_ENVIRONMENT_TYPE export JIRA_VAL_STATE_PATH export JIRA_VAL_SERVICE_ID export JIRA_VAL_ISSUE_REGEXP export JIRA_VAL_PIPELINE_ID export JIRA_VAL_PIPELINE_NUMBER export TIME_EPOCH export TIME_STAMP export COMMIT_MESSAGE export COMMIT_BODY export JIRA_BUILD_STATUS export PROJECT_SLUG export JIRA_PIPELINE_URL export JIRA_ISSUE_KEYS export JIRA_VAL_JIRA_WEBHOOK_URL export PROJECT_VCS export PROJECT_SLUG export OBR_DEBUG_ENABLE export JIRA_LOG_LEVEL main() { if [[ "$JIRA_DEBUG_ENABLE" == "true" ]]; then echo "Debugging Enabled" fi verifyVars getIssueKeys printf "Notification type: %s\n" "$JIRA_VAL_JOB_TYPE" if [[ "$JIRA_VAL_JOB_TYPE" == 'build' ]]; then PAYLOAD=$(echo "$JSON_BUILD_PAYLOAD" | circleci env subst) if ! PAYLOAD=$(jq --argjson keys "$JIRA_ISSUE_KEYS" '.builds[0].issueKeys = $keys' \<<<"$PAYLOAD");then echo "Error setting issue keys" errorOut 1 fi postForge "$PAYLOAD" elif [[ "$JIRA_VAL_JOB_TYPE" == 'deployment' ]]; then PAYLOAD=$(echo "$JSON_DEPLOYMENT_PAYLOAD" | circleci env subst) # Set the issue keys array if ! PAYLOAD=$(jq --argjson keys "$JIRA_ISSUE_KEYS" '.deployments[0].associations |= map(if .associationType == "issueIdOrKeys" then .values = $keys else . end)' \<<<"$PAYLOAD"); then echo "Error setting issue keys" errorOut 1 fi # Set ServiceID if ! PAYLOAD=$(jq --arg serviceId "$JIRA_VAL_SERVICE_ID" '.deployments[0].associations |= map(if .associationType == "serviceIdOrKeys" then .values = [$serviceId] else . end)' \<<<"$PAYLOAD"); then echo "Error setting service id" errorOut 1 fi if [[ "$JIRA_DEBUG_ENABLE" == "true" ]]; then MSG=$(printf "PAYLOAD: %s\n" "$PAYLOAD") log "$MSG" fi postForge "$PAYLOAD" else echo "Unable to determine job type" exit 1 # Critical error, do not skip fi printf "\nJira notification sent!\n\n" MSG=$(printf "sent=true") log "$MSG" } # Run the script main JIRA_VAL_ENVIRONMENT: <<parameters.environment>> JIRA_VAL_ENVIRONMENT_TYPE: <<parameters.environment_type>> JIRA_VAL_ISSUE_REGEXP: <<parameters.issue_regexp>> JIRA_VAL_JIRA_OIDC_TOKEN: <<parameters.oidc_token>> JIRA_VAL_JIRA_WEBHOOK_URL: <<parameters.webhook_url>> JIRA_VAL_JOB_TYPE: <<parameters.job_type>> JIRA_VAL_PIPELINE_ID: <<parameters.pipeline_id>> JIRA_VAL_PIPELINE_NUMBER: <<parameters.pipeline_number>> JIRA_VAL_SERVICE_ID: <<parameters.service_id>> JSON_BUILD_PAYLOAD: | { "builds": [ { "schemaVersion": "1.0", "pipelineId": "${JIRA_VAL_PIPELINE_ID}", "buildNumber": "${CIRCLE_BUILD_NUM}", "updateSequenceNumber": "${TIME_EPOCH}", "displayName": "${CIRCLE_PROJECT_REPONAME} #${CIRCLE_BUILD_NUM}", "description": "${CIRCLE_PROJECT_REPONAME} build #${CIRCLE_BUILD_NUM}: ${JIRA_BUILD_STATUS}", "label": "Build: ${CIRCLE_PROJECT_REPONAME} #${CIRCLE_BUILD_NUM}", "url": "${CIRCLE_BUILD_URL}", "state": "${JIRA_BUILD_STATUS}", "lastUpdated": "${TIME_STAMP}", "issueKeys": [] } ], "providerMetadata": { "agent": "circleci-orb" } } JSON_DEPLOYMENT_PAYLOAD: | { "deployments": [ { "deploymentSequenceNumber": "${JIRA_VAL_PIPELINE_NUMBER}", "updateSequenceNumber": "${TIME_EPOCH}", "associations": [ { "associationType": "issueIdOrKeys", "values": [] }, { "associationType": "serviceIdOrKeys", "values": [] } ], "displayName": "Deployment #${JIRA_VAL_PIPELINE_NUMBER} of ${CIRCLE_PROJECT_REPONAME}", "url": "${CIRCLE_BUILD_URL}", "description": "Deployment successful", "lastUpdated": "${TIME_STAMP}", "label": "Release ${TIME_STAMP}::${JIRA_VAL_PIPELINE_NUMBER}", "state": "${JIRA_BUILD_STATUS}", "pipeline": { "id": "${JIRA_VAL_PIPELINE_ID}", "displayName": "Deployment: ${CIRCLE_PROJECT_REPONAME}::${JIRA_VAL_PIPELINE_NUMBER}", "url": "${JIRA_PIPELINE_URL}" }, "environment": { "id": "${CIRCLE_JOB}::${JIRA_VAL_PIPELINE_ID}", "displayName": "${JIRA_VAL_ENVIRONMENT}", "type": "${JIRA_VAL_ENVIRONMENT_TYPE}" }, "schemaVersion": "1.0" } ], "providerMetadata": { "agent": "circleci-orb" } } name: Notify Jira when: always examples: send_build_notification: description: | Send build notifications to Jira as a part of your CI config. Add the notify command as the last step of your job. By default, the branch name will be used to identify the Jira issue. A 'JIRA_WEBHOOK_URL' environment variable must be provided. usage: version: "2.1" orbs: jira: circleci/jira@2.0 node: circleci/node@5.1 jobs: build: executor: node/default steps: - checkout - node/install-packages - run: command: npm test name: Test app - jira/notify: pipeline_id: << pipeline.id >> pipeline_number: << pipeline.number >> workflows: build-workflow: jobs: - build: context: JIRA_WEBHOOK send_pipelines_to_jira: description: | Send pipeline job statuses to Jira as a part of your CI config. A 'JIRA_WEBHOOK_URL' environment variable must be provided. usage: version: "2.1" orbs: jira: circleci/jira@2.0 node: circleci/node@5.1 jobs: build: executor: node/default steps: - checkout - node/install-packages - run: command: npm test name: Run tests - jira/notify: pipeline_id: << pipeline.id >> pipeline_number: << pipeline.number >> deploy: executor: node/default steps: - checkout - node/install-packages - run: command: npm run deploy name: Run Deployment - jira/notify: environment: staging environment_type: staging job_type: deployment pipeline_id: << pipeline.id >> pipeline_number: << pipeline.number >> service_id: 123456 workflows: main: jobs: - build: context: JIRA_WEBHOOK filters: tags: only: /.*/ - deploy: context: JIRA_WEBHOOK filters: branches: ignore: /.*/ tags: only: /^v.*/ requires: - build
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.