On 05/03/2011 06:01 PM, Arun C Murthy wrote:

Please find below a script that will add a fix-version to issues.

Doug

#!/bin/bash

# reads bug ids from standard input
# and adds the fixVersion named on command line

if [ $# -eq 0 ]
then
  echo "Usage: $0 bugid"
  exit 1
fi

fix=$1
echo Setting fix version to $fix.

server=https://issues.apache.org/jira
jira=./jira-cli-2.0.0/jira.sh

set -e

echo -n "Jira username: "
read user
echo -n "Jira password: "
stty -echo
read password
stty echo

while read issue
do
    # first read the old fix versions
    old=`$jira -a getFieldValue --server $server \
         --password $password --user $user \
         --issue $issue --field fixVersions | \
tail -n 1 | sed 's/([0-9]*)//g' | sed s/\'//g`

    # now update, adding new value
    # jira will ignore if this value is already present
    $jira -a updateIssue --server $server \
     --password $password --user $user \
     --issue $issue --fixVersions "${old},${fix}"
done