3 # SPDX-License-Identifier: EPL-1.0
4 ##############################################################################
5 # Copyright (c) 2019 The Linux Foundation and others.
7 # All rights reserved. This program and the accompanying materials
8 # are made available under the terms of the Eclipse Public License v1.0
9 # which accompanies this distribution, and is available at
10 # http://www.eclipse.org/legal/epl-v10.html
11 ##############################################################################
13 # A library of functions for LF/Jenkins bash scripts. In the general case, do
14 # NOT set shell variables here. If you want to make a variable available,
15 # provide a function that sets the variable: 'function lf_set_foo()
16 # {foo=asdf;}'. Any scripts that need access to the variable can call the 'set'
17 # function. This keeps the name-space polution to a minimum.
19 ################################################################################
21 ################################################################################
23 # Execute pip from 'user' venv
24 function lf-pip() { /home/jenkins/.local/bin/pip "$@" ; }
26 # Echo all arguments to stderr
27 function lf-echoerr() { echo "$@" 1>&2; }
29 # Function to safely evaluate booleans
30 # If the boolean equal '' it is an Fatal Error
31 # Note the case of boolean will be ignored (always mapped to lower-case)
34 if [[ $# != 1 ]]; then
35 echo "lf-boolean(): Missing boolean operand"
39 bool=$(echo "$1" | tr '[:upper:]' '[:lower:]')
40 if [[ -z $bool ]] ; then
41 # Output script name & line number of call to function
42 lf-echoerr "ERROR: $(basename $0) line: ${BASH_LINENO[0]} : A boolean cannot be a empty string" >&2
48 # Function to activate a Python Virtual Environment
49 # Just validate the path and add 'bin' to the path
50 function lf-activate()
52 if [[ $# != 1 ]]; then
53 echo "lf-activate(): Missing path operand"
57 # Validate the path to a VENV
58 if [[ ! -d $venv_path/bin ]]; then
59 lf-echoerr "ERROR: Is '$venv_path' a Python Environment ?"
62 PATH=$venv_path/bin:$PATH
65 ################################################################################
66 # Functions that assign Variables
67 ################################################################################
69 # These variables are shell (local) variables and need to be lower-case so
70 # Shellcheck knows they are shell variables and will check for
73 function lf-set-maven-options()
75 # shellcheck disable=SC2034 # Disable 'unused-variable' check
76 maven_options="--show-version --batch-mode -Djenkins \
77 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
78 -Dmaven.repo.local=/tmp/r -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r"