Script to easily build a package

Introduce build-fast shell script at the root of the repository to
easily build a package having version extracted from the SCM repository.

Reuses a copy of:
http://git.openstack.org/cgit/openstack-infra/project-config/tree/jenkins/scripts/version-properties.sh

Would save time for non maven guru like me.

Change-Id: Iab081de54553d6240604214c608554c6a147ae70
This commit is contained in:
Antoine Musso 2014-10-22 11:03:21 +02:00
parent fa5f0834ff
commit c9e42d6aac
3 changed files with 36 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/target
/version.properties
/work
/.config

3
build-fast Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash -eux
. version-properties.sh
mvn -Dproject-version="$PROJECT_VER" -DskipTests=true clean package

32
version-properties.sh Normal file
View File

@ -0,0 +1,32 @@
#!/bin/bash -ex
#
# This is a script that helps us version build artifacts. It retrieves
# git info and generates version strings.
#
# Source:
# http://git.openstack.org/cgit/openstack-infra/project-config/tree/jenkins/scripts/version-properties.sh
#
# get version info from scm
SCM_TAG=$(git describe --abbrev=0 --tags) || true
SCM_SHA=$(git rev-parse --short HEAD) || true
# assumes format is like this '0.0.4-2-g135721c'
COMMITS_SINCE_TAG=$(git describe | awk '{split($0,a,"-"); print a[2]}') || true
# just use git sha if there is no tag yet.
if [[ "${SCM_TAG}" == "" ]]; then
SCM_TAG=$SCM_SHA
fi
# General build version should be something like '0.0.4.3.d4ee90c'
# Release build version should be something like '0.0.5'
if [[ "${COMMITS_SINCE_TAG}" == "" ]]; then
PROJECT_VER=$SCM_TAG
else
PROJECT_VER="$SCM_TAG.$COMMITS_SINCE_TAG.$SCM_SHA";
fi
echo "SCM_SHA=$SCM_SHA" >version.properties
echo "PROJECT_VER=$PROJECT_VER" >>version.properties
echo "COMMITS_SINCE_TAG=$COMMITS_SINCE_TAG" >>version.properties