| Michael Walsh | b1a64eb | 2017-10-04 17:33:11 -0500 | [diff] [blame] | 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. | 
 | 19 | source_files="jenkins_funcs.sh" | 
 | 20 | pathlist=$(/usr/bin/which $source_files) || exit 1 | 
 | 21 | for filepath in $pathlist ; do source $filepath || exit 1 ; done | 
 | 22 |  | 
 | 23 | # Fail if an unset variable is accessed. | 
 | 24 | set -u | 
 | 25 |  | 
 | 26 | # Assign default values. | 
 | 27 | WORKSPACE="${WORKSPACE:-${HOME}}" | 
 | 28 | git_dir_path="${git_dir_path:-${WORKSPACE}}" | 
 | 29 |  | 
 | 30 | # Follow the convention of ensuring that dir paths end with slash. | 
 | 31 | WORKSPACE="${WORKSPACE%/}/" | 
 | 32 | git_dir_path="${git_dir_path%/}/" | 
 | 33 |  | 
 | 34 |  | 
 | 35 | function 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}" |