Matteo Scandolo | 3896c47 | 2017-08-01 13:31:42 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Zack Williams | 1aaa3b1 | 2016-09-01 09:55:17 -0700 | [diff] [blame] | 17 | #!/usr/bin/env bash |
| 18 | set +e |
| 19 | fail_ansible=0 |
| 20 | |
| 21 | # verify that we have ansible-lint installed |
| 22 | command -v ansible-lint >/dev/null 2>&1 || { echo "ansible-lint not found, please install it" >&2; exit 1; } |
| 23 | |
| 24 | # when not running under Jenkins, use current dir as workspace |
| 25 | WORKSPACE=${WORKSPACE:-.} |
| 26 | |
| 27 | echo "=> Linting Ansible Code with" `ansible-lint --version` |
| 28 | for f in `find $WORKSPACE -name "*.yml"`; do |
| 29 | echo "==> CHECKING: $f" |
| 30 | ansible-lint -p $f |
| 31 | rc=$? |
| 32 | if [[ $rc != 0 ]]; then |
| 33 | echo "==> LINTING FAIL: $f" |
| 34 | fail_ansible=1 |
| 35 | fi |
| 36 | done |
| 37 | |
| 38 | exit 0 |