1#!/bin/bash 2 3# Run an obmc test robot program in a docker environment. 4 5# This program is to be run from a Jenkins job such as 'Run-Robot-Program'. 6# This program expects the Jenkins job to provide several parameter values 7# as environment variables. This includes but is not limited to the 8# following: 9# WORKSPACE 10# robot_file_path 11# git_dir_path 12# post_clone_command 13# openbmc_host 14# openbmc_username 15# openbmc_password 16# additional_parms 17 18# Source other bash files containing required functions. 19source_files="jenkins_funcs.sh" 20pathlist=$(/usr/bin/which $source_files) || exit 1 21for filepath in $pathlist ; do source $filepath || exit 1 ; done 22 23# Fail if an unset variable is accessed. 24set -u 25 26# Assign default values. 27WORKSPACE="${WORKSPACE:-${HOME}}" 28git_dir_path="${git_dir_path:-${WORKSPACE}}" 29 30# Follow the convention of ensuring that dir paths end with slash. 31WORKSPACE="${WORKSPACE%/}/" 32git_dir_path="${git_dir_path%/}/" 33 34 35function mainf { 36 37 # Delete leftover output from prior runs. 38 rm -f ${WORKSPACE}*.html ${WORKSPACE}*.xml || return 1 39 process_git "${git_dir_path}" "${post_clone_command-}" || return 1 40 process_docker "${git_dir_path}" || return 1 41 42 if [ -z "${robot_file_path-}" ] ; then 43 echo "robot_file_path is blank so no there is no need to continue." 44 return 45 fi 46 47 run_docker_robot "${robot_file_path}" || return 1 48 49} 50 51 52# Main 53 54 mainf "${@}" 55 rc="${?}" 56 exit "${rc}" 57