Skip to content

Commit 60996d5

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

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

check_puppet_style/managed_script_check_style.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@
99
#
1010
# PUPPET_LINT_THREADS, PUPPET_LINT_SKIP_TESTS, PUPPET_LINT_SKIP_EXAMPLES,
1111
# PUPPET_LINT_BIN, PUPPET_LINT_FAILS_WARNING, PUPPET_LINT_FAILS_ERROR
12+
#
13+
# CHANGED_FILES: you can pass the list of files which have to be checked
1214

1315
GIT_PREVIOUS_COMMIT="${GIT_PREVIOUS_COMMIT-HEAD^}"
1416

1517
[ "$EXTRA_PATH" ] && export PATH="$EXTRA_PATH:$PATH";
1618

19+
# you can pass changed files in the variable/parameter CHANGED_FILES
20+
[ -z "$CHANGED_FILES" ] && CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT})
21+
1722
printenv | sort
1823

1924
manifests_exclude="${1-autoloader_layout}"
@@ -23,7 +28,7 @@ style_script="$(cd $(dirname "$0"); pwd)/../check_puppet_style/check_puppet_styl
2328
# Catch the modified .pp manifests, puts them in an array and use that array to peform the puppet-style checks
2429
declare -a files
2530

26-
for FILE in $(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT} | grep ".pp$");
31+
for FILE in $(echo $CHANGED_FILES | tr ' ' '\n' | grep ".pp$");
2732
do
2833
files=("${files[@]}" $FILE)
2934
done
@@ -41,7 +46,7 @@ fi
4146
# Catch the modified modules, puts them in an array and use that array to peform the puppet-style checks
4247
declare -a modules
4348

44-
for MODULE in $(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT} | grep "^modules/");
49+
for MODULE in $(echo $CHANGED_FILES | tr ' ' '\n' | grep "^modules/");
4550
do
4651
modules=("${modules[@]}" $MODULE)
4752
done

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)