macros: Manage metadata.json file in puppet-lint jobs

Since puppet 3.x, Puppet Labs Forge accept only the metadata.json file
for module description (Modulefile is now deprecated). Our puppet-lint
jobs use the Modulefile to determine module name; this patch keep the «
retro-compat. » with Modulefile, but fetch the module name in
metadata.json file if available.

Change-Id: I1738ee14706d136837b2c8fe4ffa741907291bb8
This commit is contained in:
Sebastien Badia 2014-09-27 10:50:31 +02:00
parent 9352ce12b6
commit 47c3a04c6b

View File

@ -90,10 +90,14 @@
name: puppet-lint
builders:
- shell: |
if [ -f Modulefile ]; then
MODULE=$(awk '/^name/ {print $NF}' Modulefile |tr -d \"\')
if [ -f Modulefile -o -f metadata.json ]; then
if [ -f Modulefile ]; then
MODULE=$(awk '/^name/ {print $NF}' Modulefile |tr -d \"\')
elif [ -f metadata.json ]; then
MODULE=$(python -c 'import json;print json.load(open("metadata.json"))["name"]')
fi
if [ -z "$MODULE" ]; then
echo "Module name not defined in Modulefile"
echo "Module name not defined in Modulefile or metadata.json"
else
mkdir -p "$MODULE"
rsync -a --exclude="$MODULE" --exclude ".*" . "$MODULE"