From 3a0fc42d6a01912debb9e8fbcff8a89d111ded72 Mon Sep 17 00:00:00 2001 From: Mike Marchetti Date: Fri, 17 Nov 2017 13:38:47 -0500 Subject: [PATCH] build/archive changelog for mdg Change-Id: Ia4f0a11579cd88e53477e7c9047739abc9744bf9 Signed-off-by: Mike Marchetti --- jenkins/ci-pipelines/ci_helper.groovy | 6 ++++++ jenkins/ci-pipelines/ci_stage_2.groovy | 2 ++ jenkins/ci-pipelines/ci_stage_3.groovy | 6 ++++++ tools/gen-repo.sh | 1 + tools/generatechangelog-pipeline.sh | 10 ++++++++++ tools/generatechangelog.sh | 19 +++++++++++-------- 6 files changed, 36 insertions(+), 8 deletions(-) create mode 100755 tools/generatechangelog-pipeline.sh diff --git a/jenkins/ci-pipelines/ci_helper.groovy b/jenkins/ci-pipelines/ci_helper.groovy index 21a8373f..d058099c 100644 --- a/jenkins/ci-pipelines/ci_helper.groovy +++ b/jenkins/ci-pipelines/ci_helper.groovy @@ -91,6 +91,12 @@ def archive(artifactory_server,mdg,branch,status) { def repo_prefix = 'osm-' def uploadSpec = """{ "files": [ + { + "pattern": "changelog/*", + "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/", + "props": "${properties}", + "flat": false + }, { "pattern": "dists/*.gz", "target": "${repo_prefix}${mdg}/${branch}/${BUILD_NUMBER}/", diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index 76201111..aa4a9f4b 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -62,6 +62,8 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa } stage('Archive') { + sh "mkdir changelog" + sh "devops/tools/generatechangelog-pipeline.sh > changelog/changelog-${mdg}.html" sh(returnStdout:true, script: 'devops-stages/stage-archive.sh').trim() ci_helper.archive(artifactory_server,mdg,branch,'untested') } diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 9ea2d7f2..6cb706d3 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -129,6 +129,12 @@ node("${params.NODE}") { // copy the public key into the release folder // this pulls the key from the home dir of the current user (jenkins) sh "cp ~/${REPO_KEY_NAME} ." + + // merge the change logs + sh """ + rm -f changelog/osm-changelog.html + [ -d changelog ] && for mdgchange in \$(ls changelog); do cat changelog/\$mdgchange >> changelog/osm-changelog.html; done + """ } // start an apache server to serve up the images http_server_name = "${container_name}-apache" diff --git a/tools/gen-repo.sh b/tools/gen-repo.sh index 502b941f..b1e768f4 100755 --- a/tools/gen-repo.sh +++ b/tools/gen-repo.sh @@ -113,6 +113,7 @@ mkdir -p $BASE_DIR/dists cp -R $BUILD_NUMBER/dists/$IN_REPO $BASE_DIR/dists/$OUT_REPO cp -R $BUILD_NUMBER/pool $BASE_DIR/ +[ -d "$BUILD_NUMBER/changelog" ] && cp -R $BUILD_NUMBER/changelog $BASE_DIR/ cd $BASE_DIR diff --git a/tools/generatechangelog-pipeline.sh b/tools/generatechangelog-pipeline.sh new file mode 100755 index 00000000..83a767a7 --- /dev/null +++ b/tools/generatechangelog-pipeline.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +REPO_NAME=$(basename $(git config --get remote.origin.url) | cut -d'.' -f1) +# get the latest tag +TAG_END="HEAD" +TAG_START=$(git tag | sort -Vr | head -1) +git pull --tags origin master &> /dev/null +echo "

$REPO_NAME Changelog

" +echo "

tag: ${TAG_START} -> ${TAG_END}

" +git log --pretty=format:"
  • %h • %s
  • " --reverse ${TAG_START}..${TAG_END} diff --git a/tools/generatechangelog.sh b/tools/generatechangelog.sh index 33a53022..5fa902e1 100755 --- a/tools/generatechangelog.sh +++ b/tools/generatechangelog.sh @@ -23,21 +23,24 @@ if [ -z "$list" ]; then exit 1 fi +TEMPDIR=$(mktemp -d) + echo "

    OSM Changelog

    " >> $OUTFILE for i in $list; do + REPODIR=$TEMPDIR/$i echo echo $i - if [ ! -d $i ]; then - git clone https://osm.etsi.org/gerrit/osm/$i + if [ ! -d $REPODIR ]; then + git clone https://osm.etsi.org/gerrit/osm/$i $REPODIR fi - git -C $i checkout master - git -C $i pull --rebase - git -C $i fetch --tags - TAG_START=$(git -C $i tag | sort -Vr | head -2 | sort -V | head -1) - TAG_END=$(git -C $i tag | sort -Vr | head -1) + git -C $REPODIR checkout master + git -C $REPODIR pull --rebase + git -C $REPODIR fetch --tags + TAG_START=$(git -C $REPODIR tag | sort -Vr | head -2 | sort -V | head -1) + TAG_END=$(git -C $REPODIR tag | sort -Vr | head -1) echo "

    Changes for $i tag: ${TAG_START}..${TAG_END}

    " >> $OUTFILE #git -C $i log --pretty=format:"* %h; author: %cn; date: %ci; subject:%s" ${TAG_START}..${TAG_END} >> $OUTFILE - git -C $i log --pretty=format:"
  • %h • %s
  • " --reverse ${TAG_START}..${TAG_END} >> $OUTFILE + git -C $REPODIR log --pretty=format:"
  • %h • %s
  • " --reverse ${TAG_START}..${TAG_END} >> $OUTFILE echo "" >> $OUTFILE done -- 2.25.1