Skip to content
Snippets Groups Projects
Commit 7f086fe4 authored by Recolic Keghart's avatar Recolic Keghart
Browse files

doc-update

parent 6ac3af03
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# Warning: all variable assignments in function should be changed to local variable. Don't learn from me! (I'm lazy)
_self_bin_name="$0"
function where_is_him () {
......@@ -130,12 +129,15 @@ function _select_param_and_create_json_impl () {
[[ "$kv" == "$prefix"* ]] && requiredParam_val="${kv:${#prefix}}" && requiredParam_val="${requiredParam_val/\\/\\\\}" # The backslash in json must be escaped.
done
[[ "$requiredParam_val" = "" ]] && echo2 "Note: workflow parameter $requiredParam has an empty value."
echo -n "${result_param_string}\"$requiredParam\":\"$requiredParam_val\","
echo -n "\"$requiredParam\":\"$requiredParam_val\","
done
}
function assemble_workflow_parameters () {
# Use variable $cis_default_workflow_parameter, query workflow parameter list, and fill them.
# The tail of array variable $cis_default_workflow_parameter has higher preference (because params from command line are appended after tail)
#
# returns incomplete json text in stdout, like this:
# "param1":"val1","param2":"val2",
workflow_name="$1"
params_query_response=`curl_wrapped "https://beta-cps.trafficmanager.net/cis.client.svc/Public/JobTypeDefinition/$cis_namespace" | json2table WorkflowDefinitions/InputParameters,Name -p | grep "|$workflow_name|" | cut -d '|' -f 1` || ! echo2 "Failed to get Workflow definition for workflow $workflow_name" || return $?
[[ "$params_query_response" = "[]" ]] && params="" || params=`echo "$params_query_response" | json2table Name -p | sed 's/VAL: //g' | grep -oE '[A-Za-z0-9_-]+'` || ! echo2 "Failed to get Workflow definition for workflow $workflow_name" || return $?
......@@ -144,16 +146,20 @@ function assemble_workflow_parameters () {
}
function assemble_runtime_settings () {
# Use variable $cis_default_workflow_parameter, query runtime settings list, and fill them.
# TODO: Many runtime settings have default value, I'll append them into the front of cis_default_workflow_parameter in the FUTURE!
# TODO: Many runtime settings have default value, I want to load them into cis_default_workflow_parameter automatically in the FUTURE!
# The tail of array variable $cis_default_workflow_parameter has higher preference (because params from command line are appended after tail)
#
# returns incomplete json text in stdout, like this:
# "param1":"val1","param2":"val2",
# runtime_settings are related to namespace, so we don't need workflow_name. (We're adding an '@' to all param name here)
# runtime_settings are only related to namespace, so we don't need workflow_name. (We're adding an '@' to all param name here)
params=`curl_wrapped "https://beta-cps.trafficmanager.net/cis.client.svc/Public/JobTypeDefinition/$cis_namespace" | json2table GlobalSettings/Name -p | sed 's/VAL: /@/g' | tr -d '|'` || ! echo2 "Failed to get runtime settings for namespace $cis_namespace" || return $?
echo "$params" | _select_param_and_create_json_impl | tr -d @
}
function cis_run_job () {
# returns job_id in stdout.
workflow_name="$1"
release_ver="$2"
echo2 "Submitting request to create $workflow_name:$release_ver..."
......@@ -190,6 +196,7 @@ function cis_run_job () {
function cis_get_job_status () {
# Argument should be job_id of *root* workflow. (not child workflow!)
# Returns job summary in stdout.
jobid="$1"
getjobhierarchy_apires=`curl_wrapped "https://beta-cps.trafficmanager.net/cis.client.svc/Public/$cis_namespace/GenericJob/$jobid/GetJobHierarchy"` &&
subworkflows_text=`echo "$getjobhierarchy_apires" | json2table DisplayName,Id,DisplayStatus,JobType -p` || ! echo2 "API GetJobHierarchy failed" || return $?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment