Created
August 20, 2017 18:34
-
-
Save danmayer/96c3b9ef0bc0a791223ccfd93565c63b to your computer and use it in GitHub Desktop.
Simple Jira Release Process Automation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These tasks should be called from your deploy process or countinious deployment server script, something like below | |
namespace :production do | |
desc 'production deployment' | |
task deploy: 'docker:build:push' do |t, args| | |
release_notes_and_tagging | |
end | |
end | |
### | |
# Update releases.txt file with deployed tickets | |
# Commit that file with special magic jira commit message | |
# magic commit messsage updates tickets to #deployed state in jira & adds comments for the release tag they are in | |
# Tag production release (tag ex: v201708181255) | |
### | |
def release_notes_and_tagging | |
puts 'tagging release' | |
jira_tags = jira_tags_for_release | |
stamp = `date "+%Y%m%d%H%M"`.strip | |
if jira_tags.any? | |
open('releases.txt', 'a') { |f| | |
f.puts "\n#{stamp}\n#{jira_tags.join("\n")}" | |
} | |
`git commit releases.txt -m "#{jira_tags.join(' ')} #deployed these are in release #{stamp}"` | |
`git push origin master` | |
end | |
run_cmd "git tag -a v#{stamp} -m \"release v#{stamp}\"" | |
run_cmd "git push origin v#{stamp}" | |
end | |
### | |
# Find any Jira tags mention | |
# exclude commits with WIP (work in progress) | |
# create a ignore list for any tags that follow revert in commit text | |
### | |
def jira_tags_for_release | |
last_tag = `git describe --abbrev=0`.strip | |
new_commits = `git log #{last_tag}..HEAD` | |
jira_tags = new_commits.split("\n") | |
.reject{ |line| line.match(/WIP/i) } | |
.map{ |line| line.scan(/WEB-\d+/i) }.flatten.uniq | |
ignore_tags = new_commits.split("\n") | |
.map{ |line| line.scan(/revert.*(WEB-\d+)/i) }.flatten.uniq | |
(jira_tags - ignore_tags) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment