blob: 9191387238aeeea2aa3c8b8f358cceb2bcd90d90 [file] [log] [blame]
Michael Walshb1a64eb2017-10-04 17:33:11 -05001#!/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
Patrick Williams90dfee32022-12-08 06:52:46 -060035function mainf() {
Michael Walshb1a64eb2017-10-04 17:33:11 -050036
Patrick Williams90dfee32022-12-08 06:52:46 -060037 # 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
Michael Walshb1a64eb2017-10-04 17:33:11 -050041
Patrick Williams90dfee32022-12-08 06:52:46 -060042 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
Michael Walshb1a64eb2017-10-04 17:33:11 -050046
Patrick Williams90dfee32022-12-08 06:52:46 -060047 run_docker_robot "${robot_file_path}" || return 1
Michael Walshb1a64eb2017-10-04 17:33:11 -050048
49}
50
51
52# Main
53
Patrick Williams90dfee32022-12-08 06:52:46 -060054mainf "${@}"
55rc="${?}"
56exit "${rc}"