Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable pass variable with changed files #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions check_puppet_style/managed_script_check_style.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 HEAD ${GIT_PREVIOUS_COMMIT})

printenv | sort

manifests_exclude="${1-autoloader_layout}"
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion check_puppet_syntax/JENKINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:__
Expand Down
8 changes: 6 additions & 2 deletions check_puppet_syntax/managed_script_check_puppet_syntax.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 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

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
Expand All @@ -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
Expand Down