+SUBMISSION_ATTEMPTS=5
+SUBMISSION_INITIAL_REST_INTERVAL=30 # seconds, will be doubled after each attempt
+
+#-----------------------------------------------------------------------------
+# Check for git repo changes within the last $MAX_GIT_REPO_AGE_HOURS hours
+#
+# It makes sense to set the value twice the 'cron' interval for the job (e.g.
+# if 'cron: @daily', then MAX_GIT_REPO_AGE_HOURS=48)
+
+if ! [[ "${MAX_GIT_REPO_AGE_HOURS:=0}" =~ ^[0-9]+$ ]]; then
+ echo '[ERROR] MAX_GIT_REPO_AGE_HOURS must be non-negative integer.' \
+ >&2
+ exit 1
+fi
+
+if [ ${MAX_GIT_REPO_AGE_HOURS:=0} -ne 0 ]; then
+ LAST_COMMIT_AGE=$(( $(date +%s) - $(git log -1 --pretty=format:%ct) ))
+
+ if [ $LAST_COMMIT_AGE -gt $(( MAX_GIT_REPO_AGE_HOURS *60*60 )) ]; then
+ echo '[NOTICE] Git repository did not have any commits last' \
+ "${MAX_GIT_REPO_AGE_HOURS} hours - no need to re-analyse it." \
+ >&2
+ exit 0
+ fi
+fi
+
+#-----------------------------------------------------------------------------
+# Process parameters for JS/TS/Python/Ruby/PHP files analysis
+
+if [ -n "${SEARCH_PATHS:=}" ]; then
+ for SEARCH_PATH in ${SEARCH_PATHS}; do
+ if [ -d "${SEARCH_PATH}" ]; then
+ FS_CAPTURE_SEARCH_PARAMS="${FS_CAPTURE_SEARCH_PARAMS:=} --fs-capture-search '${SEARCH_PATH}'"
+ else
+ echo "[ERROR] '${SEARCH_PATH}' from \$SEARCH_PATHS is not an" \
+ "existing directory." \
+ >&2
+ exit 1
+ fi
+ done
+
+ for EXCLUDE_REGEX in ${SEARCH_EXCLUDE_REGEXS:=}; do
+ EXCLUDE_REGEX=${EXCLUDE_REGEX//\'/\'\\\'\'} # escape single quote "'"
+ FS_CAPTURE_SEARCH_PARAMS="${FS_CAPTURE_SEARCH_PARAMS} --fs-capture-search-exclude-regex '${EXCLUDE_REGEX}'"
+
+ # FIXME: a hack to deal with temporary(?) non-functional filter to ignore
+ # specific source code parts by Coverity Scan ("--fs-capture-search-exclude-regex"
+ # CLI parameter for "cov-build" tool). The hack can be removed when this CLI
+ # parameter is fixed on Coverity side.
+ FS_CAPTURE_SEARCH_EXCLUDE_HACK_PARAMS="${FS_CAPTURE_SEARCH_EXCLUDE_HACK_PARAMS:=} --tu-pattern 'file('\\''${EXCLUDE_REGEX}'\\'')'"
+ done
+fi
+