boxboat/dockhand-jenkins

Add support build-versions metadata

matthewdevenny opened this issue · 1 comments

During image promotion pipelines extract commit log between SemVer releases and store in BoxPromote. Allow downstream clients the ability to add arbitrary metadata object to image-versions and repo-versions for promotion pipelines. Users may wish to associate issues to a release For example, you can now leverage the commits between semvers to scrape issues and store them with the build-version:

Override BoxPromote.addPromotionMetadata:

    @Override
    def addPromotionMetadata() {
        Pattern pattern = Pattern.compile("[A-Z]{2,}-\\d+")
        Set<String> issues = new LinkedHashSet<>()
        commits.each {
            Matcher matcher = pattern.matcher(it.subject)
            while(matcher.find()) {
                issues.add(matcher.group(0))
            }
        }
        metadata.put("issues", issues.toArray())
    }

Results in a build-versions entry like:

version: 0.3.18
metadata:  
  issues: [ABC-1, XY-123, XYZ-1234]

BoxDeploy has a new method getImageTagsMetadata that will allow you to retrieve the metadata associated with images you are about to deploy returning something like:

demo/dockhand-demo-app:
  version: 0.3.18
  metadata:
    issues: [ABC-1, XY-123, XYZ-1234]

This change does not break backwards compatibility but will migrate build-versions .txt files that previously contained just the SemVer text to a yaml format minimally containing:

version: <version-string>

This conversion will occur as images are build and promoted by jenkins-dockhand

Closed by #90