You are probably familiar with this workflow

  1. work on different stories
  2. pull requests are approved and merged
  3. deploy changes
  4. inform the team

For the last part, you check your todo list to get a nice description instead of some mysterious ID. You could do this manually, but this is very time-consuming, not to mention mind-numbing. Scripts to the rescue!

High level approach

  1. Fetch the version information of the environment you want to deploy to. If not yet available, I suggest you create a version endpoint and include the commit id of the lastest commit. If you work with the Java/Maven combo, then just include the Git Commit ID Maven Plugin

  2. Get all information from all commits starting from the commit id, retrieved from the version id up till the last one. Assuming you use git (and you should!) then you can use the following command

     git log <commitIdFromVersionEndpoint>..HEAD --format=format:"%s"
    
  3. Do some regex magic to extract the story id, task id, ….

  4. Connect to your backlog (REST, commandline, ….) to retrieve the information of the story id

  5. print on the console and copy to clipboard

Example script

As I am a fan of powershell, this was my go to language to implement this workflow.

# --- helper functions ---
# get all commit messages starting from the given hash
function get-commits($fromHash){
  $commits = & "git" @("log","$fromHash..HEAD", "--format=format:""%s""")
  return $commits
}

# $ticketId: the Jira ticket id
# $prefix: prefix for the message that will be returned - empty by default
function get-description($ticketId,$prefix=''){
$url = "https://<replace with jira url>/rest/api/2/search?jql=issue={0}&fields=summary,parent" -f $ticketId
$response = (curl -u <your credential> $url -s) | ConvertFrom-json

$summary = $response.issues.fields | select -ExpandProperty summary
return "{0}{1} - {2}" -f $prefix,$ticketId,$summary
}

# Step 1: get version endpoint and get the hash of the latest deployed commit
$shortCommitId = (Invoke-RestMethod https://<replace with your own endpoint>/version).gitHash

# Step 2: pull in latest changes and get all commit messages
git checkout develop
git pull
$commits = get-commits($shortCommitId)

# step 3: keep commit messages containing qntc, the Jira project key
$commits = $commits |?{$_ -like '*qntc*'}
# start building the message as an array of strings
$msg = @("Starting deploy to int. Deploy includes: ")
# Step 4: retrieve the story description
# typical powershell one-liner:
# - Loop over all commits and check for QNTC prefix
# - Sort the found prefixes
# - Select the unique values
# - Fetch the story description for each unique value
# the array of the unique story description is prefixed with '* ', and are then appended to the $msg array
$msg += ($commits |%{if($_ -match 'QNTC[SUP]*-\d+') {$Matches[0]}} | sort| select -unique | %{get-description $_ '* '})
# copy the message to the clipboard
$msg | pbcopy
Write-Host 'copied to clipboard'

That’s it! I’m sure you can implement this in your favourite scripting language

References