From 68db52030ab9547742329805444bdd458526dadc Mon Sep 17 00:00:00 2001 From: Deepshikha khandelwal Date: Fri, 16 Nov 2018 12:18:33 +0530 Subject: Non-voting job to validate shell script using ShellCheck tool Change-Id: If0077909dd7e2b734f551c53e230a03c65265350 --- build-gluster-org/jobs/shellcheck.yml | 60 +++++++++++++++++++++++++++++++++ build-gluster-org/scripts/shellcheck.sh | 22 ++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 build-gluster-org/jobs/shellcheck.yml create mode 100644 build-gluster-org/scripts/shellcheck.sh (limited to 'build-gluster-org') diff --git a/build-gluster-org/jobs/shellcheck.yml b/build-gluster-org/jobs/shellcheck.yml new file mode 100644 index 0000000..2948e51 --- /dev/null +++ b/build-gluster-org/jobs/shellcheck.yml @@ -0,0 +1,60 @@ +- job: + name: shellcheck + node: smoke7 + description: shell script validation using ShellCheck tool + project-type: freestyle + concurrent: true + + scm: + - glusterfs + + properties: + - discard-after-x: + x: 30 + - one-build-per-node + + triggers: + - gerrit: + trigger-on: + - patchset-created-event: + exclude-drafts: false + exclude-trivial-rebase: false + exclude-no-code-change: false + - draft-published-event + - comment-added-contains-event: + comment-contains-value: "recheck smoke" + server-name: review.gluster.org_for-smoke-jobs + skip-vote: + failed: true + unstable: true + notbuilt: true + projects: + - project-compare-type: 'PLAIN' + project-pattern: 'glusterfs' + branches: + - branch-compare-type: 'ANT' + branch-pattern: '**' + + parameters: + - string: + default: refs/heads/master + description: 'For review 12345 and patch set 6, this will be refs/changes/45/12345/6. Default: Tip of master' + name: GERRIT_REFSPEC + - string: + default: master + description: 'Name of the branch you want to build from. We usually build from master' + name: GERRIT_BRANCH + + builders: + - shell: !include-raw: ../scripts/shellcheck.sh + + publishers: + - archive: + allow-empty: true + artifacts: "shellcheck.txt" + default-excludes: true + fingerprint: false + only-if-success: false + + wrappers: + - timestamps diff --git a/build-gluster-org/scripts/shellcheck.sh b/build-gluster-org/scripts/shellcheck.sh new file mode 100644 index 0000000..f5e2278 --- /dev/null +++ b/build-gluster-org/scripts/shellcheck.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +./autogen.sh +./configure --disable-bd-xlator --enable-debug --enable-gnfs --silent + +find . -path ./.git -prune -o -path ./tests -prune -o -exec file {} \; \ + | grep "shell script" \ + | cut -d: -f 1 \ + | xargs shellcheck \ + >shellcheck.txt + +SHELLCHECK_COUNT="$(grep -c 'In' shellcheck.txt)" + +#fail build if there's any issue or warning +if [[ "$SHELLCHECK_COUNT" -gt 0 ]]; then + echo "" + echo "=========================================================" + echo " Result of ShellCheck" + echo " Number of ShellCheck errors/warnings: ${SHELLCHECK_COUNT}" + echo "=========================================================" + exit 1 +fi -- cgit