Tuesday, 23 June 2020

Run jq in docker

# Get Slack_name from a.json
declare -A buildUserId2SlackNameDic
while IFS='|' read -r key value; do
  key=$(echo $key | tr -d '"')
  value=$(echo $value | tr -d '"')
  if test ! -z "$value" ; then
  buildUserId2SlackNameDic[$key]=$value
  fi
done< <(docker run -i stedolan/jq <a.json '.[] | "\(.user)|\(.Slack_name)"')

# Get SLACK_USER
if test "${buildUserId2SlackNameDic[$SLACK_USER_ID]+isset}" ; then
    SLACK_USER=${buildUserId2SlackNameDic[$SLACK_USER_ID]}
else
    SLACK_USER=${BUILD_USER_FIRST_NAME,,}
fi

No comments:

Post a Comment

How to check if a file contains a specific string using Bash

 In case if you want to check whether file does not contain a specific string, you can do it as follows. if ! grep -q SomeString "$File...