Created
November 14, 2017 20:56
-
-
Save askb/e72c21c944524b0e5db33e5dbce418cb to your computer and use it in GitHub Desktop.
exit: : numeric argument required
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
function bugid_to_jira_task() { | |
local jira_url="${1}" | |
local project="${2}" | |
local bug_id="${3}" | |
local resp=$(curl -sS --stderr -w {%http_code} --H "Accept: application/json" "${jira_url}/rest/api/2/search\?jql\=project\=${project}%20and%20\\"External%20issue%20ID\\"\~${bug_id}") | |
echo "$resp" | |
local issue_id=$(echo "$resp"| jq -r '.issues[].key') | |
echo "$issue_id" | |
local status=$(echo "$resp" | awk 'END {print $NF}') | |
if [ "$status" != "201" ]; then | |
echo "ERROR: Failed to run. Aborting..." | |
echo "$resp" | |
exit "$status" | |
fi | |
return $? | |
} | |
JIRA_URL="https://jira.opendaylight.org" | |
buglist=("9228", "2942") | |
buglist=(${buglist//,/ }) | |
projectlist=("odlparent", "controller") | |
projectlist=(${projectlist//,/ }) | |
if hash parallel 2>/dev/null; then | |
export -f bugid_to_jira_task | |
parallel --verbose -vv --jobs 200% --xapply "bugid_to_jira_task ${JIRA_URL} {1} {2}" ::: ${projectlist[*]} ::: ${buglist[*]} | |
fi |
Author
askb
commented
Nov 14, 2017
•
#!/bin/bash
function convert_bugid_to_jira_task() {
local jira_url="${1}"
local project="${2}"
local bug_id="${3}"
local resp=$(curl -sS -w %{http_code} --header "Accept: application/json" -o /tmp/${project}-${bug_id}.json \
${jira_url}/rest/api/2/search\?jql\=project\=${project}%20and%20\"External%20issue%20ID\"\~${bug_id})
#echo "${resp}"
local issue_id=$(cat /tmp/${project}-${bug_id}.json | jq -r '.issues[].key')
echo "$issue_id"
local status=$(echo "$resp" | awk 'END {print $NF}')
#echo "$status"
if [ "$status" != "200" ]; then
echo "ERROR: Failed to run. Aborting..."
echo "$resp"
exit "$status"
fi
return $?
}
JIRA_URL="https://jira.opendaylight.org"
buglist=("9228" "2942" "9040" "8987" "9060" "9008" "8900" "9145" "9132" "8976")
#buglist=(${buglist//,/ })
projectlist=("odlparent" "controller" "aaa" "bgpcep" "controller" "controller" "gbp" "mdsal" "netconf" "netvirt")
#projectlist=(${projectlist//,/ })
if hash parallel1 2>/dev/null; then
export -f convert_bugid_to_jira_task
parallel --no-notice --jobs 200% --xapply "convert_bugid_to_jira_task ${JIRA_URL} {1} {2}" ::: ${projectlist[*]} ::: ${buglist[*]}
else
length=${#buglist[@]}
for ((i=0; i<=$length; i++)); do
if [[ ! -z ${projectlist[$i]} ]] && [[ ! -z ${buglist[$i]} ]]; then
convert_bugid_to_jira_task "${JIRA_URL}" ${projectlist[$i]} ${buglist[$i]}
fi
done
fi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment