From 60996d5b317e4bf181bf8b8732120916810a083c Mon Sep 17 00:00:00 2001 From: Pavel Pulec Date: Wed, 26 Aug 2015 11:07:07 +0200 Subject: [PATCH 1/3] enable pass variable with changed files --- check_puppet_style/managed_script_check_style.sh | 9 +++++++-- .../managed_script_check_puppet_syntax.sh | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/check_puppet_style/managed_script_check_style.sh b/check_puppet_style/managed_script_check_style.sh index 8781d6c..f8f37c1 100755 --- a/check_puppet_style/managed_script_check_style.sh +++ b/check_puppet_style/managed_script_check_style.sh @@ -9,11 +9,16 @@ # # PUPPET_LINT_THREADS, PUPPET_LINT_SKIP_TESTS, PUPPET_LINT_SKIP_EXAMPLES, # PUPPET_LINT_BIN, PUPPET_LINT_FAILS_WARNING, PUPPET_LINT_FAILS_ERROR +# +# CHANGED_FILES: you can pass the list of files which have to be checked GIT_PREVIOUS_COMMIT="${GIT_PREVIOUS_COMMIT-HEAD^}" [ "$EXTRA_PATH" ] && export PATH="$EXTRA_PATH:$PATH"; +# you can pass changed files in the variable/parameter CHANGED_FILES +[ -z "$CHANGED_FILES" ] && CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT}) + printenv | sort manifests_exclude="${1-autoloader_layout}" @@ -23,7 +28,7 @@ style_script="$(cd $(dirname "$0"); pwd)/../check_puppet_style/check_puppet_styl # Catch the modified .pp manifests, puts them in an array and use that array to peform the puppet-style checks declare -a files -for FILE in $(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT} | grep ".pp$"); +for FILE in $(echo $CHANGED_FILES | tr ' ' '\n' | grep ".pp$"); do files=("${files[@]}" $FILE) done @@ -41,7 +46,7 @@ fi # Catch the modified modules, puts them in an array and use that array to peform the puppet-style checks declare -a modules -for MODULE in $(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT} | grep "^modules/"); +for MODULE in $(echo $CHANGED_FILES | tr ' ' '\n' | grep "^modules/"); do modules=("${modules[@]}" $MODULE) done diff --git a/check_puppet_syntax/managed_script_check_puppet_syntax.sh b/check_puppet_syntax/managed_script_check_puppet_syntax.sh index 6dc7804..282ae5f 100755 --- a/check_puppet_syntax/managed_script_check_puppet_syntax.sh +++ b/check_puppet_syntax/managed_script_check_puppet_syntax.sh @@ -4,16 +4,20 @@ # Variables to be set: PUPPET_SYNTAX_THREADS, PUPPET_BIN, ERB_BIN, RUBY_BIN # # scripts_job_name: Name of the jenkins job which is used to pull this repo into your jenkins environment +# CHANGED_FILES: you can pass the list of files which have to be checked [ -n $GIT_PREVIOUS_COMMIT ] || GIT_PREVIOUS_COMMIT='HEAD^' [ "$EXTRA_PATH" ] && export PATH="$EXTRA_PATH:$PATH"; scripts_job_name="scripts/puppet" +# you can pass changed files in the variable/parameter CHANGED_FILES +[ -z "$CHANGED_FILES" ] && CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT}) + # Catch the modified .pp manifests, puts them in an array and use that array to peform the puppet-syntax checks declare -a files -for FILE in $(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT} | grep ".pp$"); +for FILE in $(echo $CHANGED_FILES | tr ' ' '\n' | grep ".pp$"); do files=("${files[@]}" $FILE) done @@ -31,7 +35,7 @@ fi # Catch the modified modules, puts them in an array and use that array to peform the puppet-style checks declare -a modules -for MODULE in $(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT} | grep "^modules/"); +for MODULE in $(echo $CHANGED_FILES | tr ' ' '\n' | grep "^modules/"); do modules=("${modules[@]}" $MODULE) done From 295a433b57b91b5b2e3e0c5940c3c48d7a065450 Mon Sep 17 00:00:00 2001 From: Pavel Pulec Date: Wed, 26 Aug 2015 12:06:30 +0200 Subject: [PATCH 2/3] syntax error - git diff compared to the HEAD --- check_puppet_style/managed_script_check_style.sh | 2 +- check_puppet_syntax/managed_script_check_puppet_syntax.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/check_puppet_style/managed_script_check_style.sh b/check_puppet_style/managed_script_check_style.sh index f8f37c1..45bd4f3 100755 --- a/check_puppet_style/managed_script_check_style.sh +++ b/check_puppet_style/managed_script_check_style.sh @@ -17,7 +17,7 @@ GIT_PREVIOUS_COMMIT="${GIT_PREVIOUS_COMMIT-HEAD^}" [ "$EXTRA_PATH" ] && export PATH="$EXTRA_PATH:$PATH"; # you can pass changed files in the variable/parameter CHANGED_FILES -[ -z "$CHANGED_FILES" ] && CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT}) +[ -z "$CHANGED_FILES" ] && CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB HEAD ${GIT_PREVIOUS_COMMIT}) printenv | sort diff --git a/check_puppet_syntax/managed_script_check_puppet_syntax.sh b/check_puppet_syntax/managed_script_check_puppet_syntax.sh index 282ae5f..187c507 100755 --- a/check_puppet_syntax/managed_script_check_puppet_syntax.sh +++ b/check_puppet_syntax/managed_script_check_puppet_syntax.sh @@ -12,7 +12,7 @@ scripts_job_name="scripts/puppet" # you can pass changed files in the variable/parameter CHANGED_FILES -[ -z "$CHANGED_FILES" ] && CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB ${GIT_PREVIOUS_COMMIT}) +[ -z "$CHANGED_FILES" ] && CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB HEAD ${GIT_PREVIOUS_COMMIT}) # Catch the modified .pp manifests, puts them in an array and use that array to peform the puppet-syntax checks declare -a files From 7b642936814dc7e5fcd452f2377217033291fb68 Mon Sep 17 00:00:00 2001 From: Pavel Pulec Date: Wed, 26 Aug 2015 16:26:09 +0200 Subject: [PATCH 3/3] fix regular expression for Jenkins --- check_puppet_syntax/JENKINS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_puppet_syntax/JENKINS.md b/check_puppet_syntax/JENKINS.md index b910ab6..94137fe 100644 --- a/check_puppet_syntax/JENKINS.md +++ b/check_puppet_syntax/JENKINS.md @@ -8,7 +8,7 @@ You can obviously choose the name for the parser and the trend graph. __Regular Expression:__ ``` -^PUPPET_SYNTAX[^:]*:(.*):.*(warning|err|Error):\s*(.*)$ +^PUPPET_SYNTAX[^:]*:(.*):.*(warning|Warning|err|Error):\s*(.*)$ ``` __Mapping Script:__