Skip to content

Commit 064c01f

Browse files
author
Pavel Pulec
committed
enable pass variable with changed files
1 parent 26ada7c commit 064c01f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

check_puppet_syntax/managed_script_check_puppet_syntax.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44
# Variables to be set: PUPPET_SYNTAX_THREADS, PUPPET_BIN, ERB_BIN, RUBY_BIN
55
#
66
# scripts_job_name: Name of the jenkins job which is used to pull this repo into your jenkins environment
7+
# CHANGED_FILES: you can pass the list of files which have to be checked
78

89
[ -n $GIT_PREVIOUS_COMMIT ] || GIT_PREVIOUS_COMMIT='HEAD^'
910

1011
[ "$EXTRA_PATH" ] && export PATH="$EXTRA_PATH:$PATH";
1112
scripts_job_name="scripts/puppet"
1213

14+
# you can pass changed files in the variable/parameter CHANGED_FILES
15+
[ -z "$CHANGED_FILES" ] && CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT})
16+
1317
# Catch the modified .pp manifests, puts them in an array and use that array to peform the puppet-syntax checks
1418
declare -a files
1519

16-
for FILE in $(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT} | grep ".pp$");
20+
for FILE in $(echo $CHANGED_FILES | tr ' ' '\n' | grep ".pp$");
1721
do
1822
files=("${files[@]}" $FILE)
1923
done
@@ -31,7 +35,7 @@ fi
3135
# Catch the modified modules, puts them in an array and use that array to peform the puppet-style checks
3236
declare -a modules
3337

34-
for MODULE in $(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT} | grep "^modules/");
38+
for MODULE in $(echo $CHANGED_FILES | tr ' ' '\n' | grep "^modules/");
3539
do
3640
modules=("${modules[@]}" $MODULE)
3741
done

0 commit comments

Comments
 (0)