Search code examples
jenkinsjenkins-pluginshockeyapp

Release notes creation for HockeyApp in Jenkins promotion phase


Jenkins HockeyApp plugin can automatically create reasonably nicely formatted release notes from git changes. However, this does not seem to work if HockeyApp upload is done in promotion phase, using promotion plugin. In that case the change log is empty.

This can be partially solved by selecting "Load Release Notes from File" and giving path to changelog.xml in the project (../builds/${PROMOTED_NUMBER}/changelog.xml), but the output is not as clean as it is with the "Use Change Log" selection, containing also the file names and commit id's.

What is the best way to automatically create nicely formatted logs for HockeyApp transfer, when the transfer happens in promotion phase and possibly on a Jenkins slave machine?


Solution

  • Answering to myself: It is possible to get the change log from jenkins master to jenkins slave and parsing the obtained changelog.xml to more user readable by using this simple script:

    #!/bin/bash
    
    PROJECT_NAME="$1"
    BUILD_NUMBER="$2"
    BUILD_DATE="$3"
    CHANGELOG=changelog.xml
    
    echo "project=${PROJECT_NAME} build=${BUILD_NUMBER}"
    
    PROJECT_NAME=`basename ${PROJECT_NAME}`
    
    curl ${PROMOTED_URL}api/xml?xpath=/*/changeSet/item/comment\&wrapper=changelog > ${CHANGELOG}
    
    PARSEDLOG=`sed -e 's/<\/[^>]*>/€€/g' ${CHANGELOG} | sed -e 's/<[^>]*>/- /g' | tr €€, '\r' | sed '/^ \s*$/d'`
    
    echo "${PROJECT_NAME} ${BUILD_NUMBER} ${BUILD_DATE} change log:
    =====================================================================
    ${PARSEDLOG}" > changelog.txt
    

    I know there are much better and reliable ways to clean up the xml than the sequence of sed and tr commands I have used, but this works for now.