Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ This command receives the following parameters to performs the API calls:
deployments.
- `acsf-user`: Sets the acsf user account.
- `acsf-site`: Sets the project site. You can get this value looking at your acsf url: `https://www.[env]-[site].acsitefactory.com`
- `slack-channel`: The Slack Channel to send notifications.
- `with-jira`: Boolean. If set to "true" it will transition tickets on the Jira project.
- `jira-transition-id`: The Jira transition ID.
- `jira-url`: The Jira Cloud URL
- `jira-project`: The Jira Project key for which we should transition tickets.

**NOTE**: To perform API calls to the site factory is recommended to create a "machine" user in the site factory
(in each environment!). This user should have the role "release engineer" to have the correct permissions to use the
Expand All @@ -78,6 +83,7 @@ This command receives the following parameters:
- `env`: The environment where to deploy. It's default value is "test"
- `jira-url`: The Jira Cloud URL
- `jira-transition-id`: The Jira transition ID
- `jira-project`: The Jira project key, to transition only tickets in the specified project.

**NOTE:** To avoid setting the auth token in your config files, you must define it as an CircleCI Environment Variable.

Expand Down
7 changes: 6 additions & 1 deletion src/commands/jira-transition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ parameters:
jira-transition-id:
type: string
default: ""
description: "The Jira transition ID"
description: 'The Jira transition ID'
jira-auth:
type: env_var_name
default: JIRA_AUTH
jira-project:
type: string
default: ""
description: 'The Jira Project key for which we should transition tickets.'
steps:
- run:
when: on_success
Expand All @@ -41,4 +45,5 @@ steps:
JIRA_URL: << parameters.jira-url >>
JIRA_TRANS_ID: << parameters.jira-transition-id >>
JIRA_AUTH_TOKEN: "$<< parameters.jira-auth >>"
JIRA_PROJECT: << parameters.jira-project >>
command: <<include(scripts/jira-transition.sh)>>
4 changes: 4 additions & 0 deletions src/examples/use_acsf_jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ usage:
acsf-env: "test"
acsf-deploy-type: "code, db"
slack-channel: "@your_channel"
jira-transition-id: "3"
jira-url: "https://your.jira.url"
jira-project: "ABC"
img-version: "latest"
mk_message: "## Deployment started ✨"
requires:
- approve-deployment
32 changes: 17 additions & 15 deletions src/jobs/deploy-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ parameters:
default: ""
type: string
description: 'The Jira Cloud URL'
jira-project:
default: ""
type: string
description: 'The Jira Project key for which we should transition tickets.'
tag:
default: $CIRCLE_TAG
type: string
Expand All @@ -50,6 +54,13 @@ parameters:
Pick a specific mobomo/drupalstand-ci image variant:
https://hub.docker.com/r/mobomo/drupalstand-ci/tags
type: string
mk_message:
default: "## Deployment started ✨"
type: string
description: >
The message to display on Slack channel when the
deployment starts. It must be a string and supports Markdown.
Do not include the "```" quotes.
steps:
- checkout
- compare-tags:
Expand All @@ -73,6 +84,7 @@ steps:
acsf-site: << parameters.acsf-site >>
jira-transition-id: << parameters.jira-transition-id >>
jira-url: << parameters.jira-url >>
jira-project: << parameters.jira-project >>
- slack/notify:
event: pass
channel: << parameters.slack-channel >>
Expand All @@ -91,7 +103,7 @@ steps:
"type": "section",
"text": {
"type": "mrkdwn",
"text": "``` _______________________\n/ Deployment completed \\\n\\ Find info below me /\n -----------------------\n \\ ^__^\n \\ (oo)\\_______\n (__)\\ )\\/\\\n ||----w |\n || ||```"
"text": "```<< parameters.mk_message >>```"
}
},
{
Expand All @@ -113,6 +125,10 @@ steps:
"type": "mrkdwn",
"text": "*Tag:*\n<< parameters.tag >>"
},
{
"type": "mrkdwn",
"text": "*Jira Project:*\n$JIRA_PROJECT"
},
{
"type": "mrkdwn",
"text": "*Tickets:*\n$JIRA_ISSUES"
Expand All @@ -137,20 +153,6 @@ steps:
}
]
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://pbs.twimg.com/profile_images/625633822235693056/lNGUneLX_400x400.jpg",
"alt_text": "cute cat"
},
{
"type": "mrkdwn",
"text": "*cat* approved this message :heavy_check_mark:"
}
]
},
{
"type": "divider"
}
Expand Down
6 changes: 4 additions & 2 deletions src/scripts/jira-transition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -eu
# VARS EVAL.
TAG_TO_DEPLOY=$(eval echo "$TAG")
JIRA_TOKEN=$(eval echo "$JIRA_AUTH_TOKEN")
#JIRA_PROJECT=$(eval echo "$JIRA_PROJECT")

# Determine acquia environment, since acsf user/keys are per env.
get-acquia-key() {
Expand Down Expand Up @@ -38,11 +39,11 @@ get-current-tag() {
CURRENT_TAG=$(get-current-tag)
echo "Current Tag on ${ACSF_ENV}: $CURRENT_TAG"

# With the the current tag, get a list of issues IDs that were committed between current and latest.
# With the the current tag, get a list of issues IDs that were committed between current and latest. Filtering by Jira Project Key.
get-jira-issues() {
local JIRA_ISSUES
if [ -n "${CURRENT_TAG}" ]; then
JIRA_ISSUES=$(git log "${CURRENT_TAG}".."${TAG_TO_DEPLOY}" | grep -e '[A-Z]\+-[0-9]\+' -o | sort -u | tr '\n' ',' | sed '$s/,$/\n/')
JIRA_ISSUES=$(git log "${CURRENT_TAG}".."${TAG_TO_DEPLOY}" | grep -e "${JIRA_PROJECT}-[0-9]\+" -o | sort -u | tr '\n' ',' | sed '$s/,$/\n/')
echo "$JIRA_ISSUES"
else
echo "We were not able to get current tag deployed to ACSF Env. Please check the 'acsf-' parameters are correctly set."
Expand All @@ -55,6 +56,7 @@ transition-issues() {
if [ -n "${JIRA_ISSUES}" ]; then
echo "Included tickets between ${CURRENT_TAG} and ${TAG_TO_DEPLOY}: ${JIRA_ISSUES}"
echo "export JIRA_ISSUES=$(get-jira-issues)" >> "$BASH_ENV"
echo "export JIRA_PROJECT=${JIRA_PROJECT}" >> "$BASH_ENV"
for issue in ${JIRA_ISSUES//,/ }
do
echo "Transitioning $issue..."
Expand Down