Commit 21530419 authored by cpomies's avatar cpomies
Browse files

Used parameter instead of environment variable

parent eda15d51
......@@ -15,8 +15,17 @@
# Set common environment
set_common
get_configs_folder
checkout_slot
checkout_slot \
"${flavour}" \
"${slot}" \
"${slot_build_id}" \
"${ARTIFACTS_DIR}" \
"${build_tool}" \
"${platforms}" \
"${packages_list}" \
"${peojects_list}"
push_artifact "${ARTIFACTS_DIR}" "${flavour}" "${slot}" "${slot_build_id}"
check_preconditions
check_preconditions "${config_file_checkout}"
......@@ -14,4 +14,4 @@
set_common
get_configs_folder
extract_enabled_slots
extract_enabled_slots "${flavour}" "${slots}"
......@@ -14,4 +14,4 @@
set_common
get_config_file "${flavour}" "${slot}" "${slot_build_id}" "${ARTIFACTS_DIR}"
execute_preconditions
execute_preconditions "${config_file}"
function check_preconditions {
local USAGE="check_preconditions config_file"
if [ $# != 1 ] ; then
echo "ERROR : Usage : ${USAGE}"
exit 1
fi
if [ "$SET_COMMON" != "true" -o "$CONFIG_FILE_CHECKOUT" != "true" ] ; then
echo "ERROR : $0 need SET_COMMON and CONFIG_FILE_CHECKOUT set with true"
exit 1
fi
lbn-check-preconditions --verbose ${config_file_checkout}
local config="$1"
lbn-check-preconditions --verbose "${config}"
}
function checkout_slot {
local USAGE="checkout_slot flavour slot slot_build_id directory [build_tool platforms packages_list projects_list]"
if [ $# < 4 ] ; then
echo "ERROR : Usage : ${USAGE}"
exit 1
fi
local flavour=$1
local slot=$2
local slot_build_id=$3
local directory=$4
local build_tool=$5
local platforms=$6
local packages_list=$7
local projects_list=$8
if [ "$SET_COMMON" != "true" -o "$GET_CONFIGS_FOLDER" != "true" ] ; then
echo "ERROR : $0 need SET_COMMON and GET_CONFIGS_FOLDER set with true"
......@@ -35,7 +53,7 @@ function checkout_slot {
ignore_error_opt=--no-ignore-checkout-errors
fi
lbn-checkout --verbose --build-id "${slot}.${slot_build_id}" --artifacts-dir "${ARTIFACTS_DIR}" ${submit_opt} ${ignore_error_opt} ${config_file_checkout}
lbn-checkout --verbose --build-id "${slot}.${slot_build_id}" --artifacts-dir "${directory}" ${submit_opt} ${ignore_error_opt} ${config_file_checkout}
# We need to copy the configuration at the end because
# StachCkeckout.py cleans the artifacts before starting
......@@ -45,9 +63,9 @@ function checkout_slot {
if [ "${flavour}" = "release" ] ; then
# Now preparing the RPM with the project source
time lbn-rpm --shared --verbose --build-id "${slot}.${slot_build_id}" --artifacts-dir "${ARTIFACTS_DIR}" ${config_file_checkout}
time lbn-rpm --shared --verbose --build-id "${slot}.${slot_build_id}" --artifacts-dir "${directory}" ${config_file_checkout}
if [ -n "${packages_list}" ] ; then
time lbn-rpm --datapkg --verbose --build-id "${slot}.${slot_build_id}" --artifacts-dir "${ARTIFACTS_DIR}" ${config_file_checkout}
time lbn-rpm --datapkg --verbose --build-id "${slot}.${slot_build_id}" --artifacts-dir "${directory}" ${config_file_checkout}
fi
fi
......
function execute_preconditions {
local USAGE="execute_preconditions config_file"
if [ $# != 1 ] ; then
echo "ERROR : Usage : ${USAGE}"
exit 1
fi
if [ "$SET_COMMON" != "true" -o "$GET_CONFIG_FILE" != "true" ] ; then
echo "ERROR : $0 need SET_COMMON and GET_CONFIG_FILE set with true"
exit 1
fi
lbn-preconditions --verbose ${config_file}
local config="$1"
lbn-preconditions --verbose "${config}"
}
\ No newline at end of file
function extract_enabled_slots {
local USAGE="extract_enabled_slots flavour [slots]"
if [ $# != 1 -a $# != 2 ] ; then
echo "ERROR : Usage : ${USAGE}"
exit 1
fi
if [ "$SET_COMMON" != "true" -o "$GET_CONFIGS_FOLDER" != "true" ] ; then
echo "ERROR : $0 need SET_COMMON and GET_CONFIGS_FOLDER set with true"
exit 1
fi
lbn-enabled-slots --verbose 'slot-params-{0}.txt' ${slots}
local flavour="$1"
local slots="$2"
lbn-enabled-slots --verbose "${flavour}" "slot-params-{0}.txt" ${slots}
}
function get_config_file {
USAGE="get_config_file flavour slot slot_build_id directory_dest"
local USAGE="get_config_file flavour slot slot_build_id directory_dest"
if [ $# != 4 ] ; then
echo "ERROR : Usage : ${USAGE}"
exit 1
fi
flavour="$1"
slot="$2"
slot_build_id="$3"
DESTINATION="$4"
local flavour="$1"
local slot="$2"
local slot_build_id="$3"
local DESTINATION="$4"
SOURCE=$(get_remote_directory "$flavour" "$slot" "$slot_build_id")
local SOURCE=$(get_remote_directory "$flavour" "$slot" "$slot_build_id")
lbn-manage-rsync --verbose --get-config "${SOURCE}" "${DESTINATION}"
lbn-manage-remote --verbose --get-config "${SOURCE}" "${DESTINATION}"
if [ -e ${DESTINATION}/${slot}.json ] ; then
export config_file=${DESTINATION}/${slot}.json
......
......@@ -3,20 +3,20 @@ export RSYNC_WORKDIR=${RSYNC_WORKDIR:-/data/artifacts}
function get_remote_directory {
USAGE="get_directory_rsync flavour slot slot_build_id"
local USAGE="get_directory_rsync flavour slot slot_build_id"
if [ $# != 3 ] ; then
echo "ERROR : Usage : ${USAGE}"
exit 1
fi
flavour="$1"
slot="$2"
slot_build_id="$3"
local flavour="$1"
local slot="$2"
local slot_build_id="$3"
RSYNC_DIR="${RSYNC_WORKDIR}/${flavour}/${slot}/${slot_build_id}"
local RSYNC_DIR="${RSYNC_WORKDIR}/${flavour}/${slot}/${slot_build_id}"
if [ ! -d "${RSYNC_DIR}" ] ; then
RSYNC_DIR="${RSYNC_SERVER}:${RSYNC_DIR}"
local RSYNC_DIR="${RSYNC_SERVER}:${RSYNC_DIR}"
fi
echo "${RSYNC_DIR}"
......
function get_sources {
USAGE="get_sources flavour slot slot_build_id directory_dest"
local USAGE="get_sources flavour slot slot_build_id directory_dest"
if [ $# != 4 ] ; then
echo "ERROR : Usage : ${USAGE}"
exit 1
fi
flavour="$1"
slot="$2"
slot_build_id="$3"
DESTINATION="$4"
local flavour="$1"
local slot="$2"
local slot_build_id="$3"
local DESTINATION="$4"
SOURCE=$(get_remote_directory "$flavour" "$slot" "$slot_build_id")
local SOURCE=$(get_remote_directory "$flavour" "$slot" "$slot_build_id")
lbn-manage-rsync --verbose --get-sources "${SOURCE}" "${DESTINATION}"
lbn-manage-remote --verbose --get-sources "${SOURCE}" "${DESTINATION}"
export GET_SOURCES="true"
}
function push_artifact {
USAGE="push_artifact directory_src flavour slot slot_build_id "
local USAGE="push_artifact directory_src flavour slot slot_build_id "
if [ $# != 4 ] ; then
echo "ERROR : Usage : ${USAGE}"
exit 1
fi
SOURCE="$1"
flavour="$2"
slot="$3"
slot_build_id="$4"
local SOURCE="$1"
local flavour="$2"
local slot="$3"
local slot_build_id="$4"
DESTINATION=$(get_remote_directory "$flavour" "$slot" "$slot_build_id")
local DESTINATION=$(get_remote_directory "$flavour" "$slot" "$slot_build_id")
lbn-manage-rsync --verbose "${SOURCE}" "${DESTINATION}"
lbn-manage-remote --verbose "${SOURCE}" "${DESTINATION}"
}
......@@ -30,7 +30,7 @@ class Script(LbUtils.Script.PlainScript):
This file contain the slot name and the slot build id
The slot build id is extract with the function get_ids
'''
__usage__ = '%prog [options] <output_file.txt> [<slot1> <slot2> ...]'
__usage__ = '%prog [options] flavour <output_file.txt> [<slot1> <slot2> ...]'
__version__ = ''
def extract_from_json(self, file_format_json):
......@@ -83,9 +83,8 @@ class Script(LbUtils.Script.PlainScript):
return slots
def write_files(self, slots, output_file):
slot_ids = get_ids(slots)
# get_id = lambda slot: get_ids([slot]])[slot]
def write_files(self, slots, flavour, output_file):
slot_ids = get_ids(slots, flavour)
for slot in slots:
output_file_name = output_file.format(slot)
slot_build_id=slot_ids[slot]
......@@ -101,11 +100,12 @@ class Script(LbUtils.Script.PlainScript):
self.log.info('%s slots to start', len(slots))
def main(self):
if len(self.args) < 1:
if len(self.args) < 2:
self.parser.error('wrong number of arguments')
output_file = self.args[0]
slots = self.args[1:]
flavour = self.args[0]
output_file = self.args[1]
slots = self.args[2:]
if not slots:
self.log.info('Starting extraction of all enable slot')
......@@ -113,7 +113,7 @@ class Script(LbUtils.Script.PlainScript):
self.extract_from_xml('configs/configuration.xml')
# Create a file that contain JobParams for each slot
self.write_files(slots, output_file)
self.write_files(slots, flavour, output_file)
self.log.info('End of extraction of all enable slot')
......
......@@ -36,10 +36,10 @@ def indent(elem, level=0):
elem.tail = i
def get_ids(slots):
def get_ids(slots, flavour):
slot_id_dir = os.path.join(os.environ['JENKINS_HOME'],
'nightlies',
os.environ['flavour'])
flavour)
# slot_id_dir = 'configs'
slot_id_file = os.path.join(slot_id_dir, 'slot_ids.xml')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment