Sample Validation Program

Related Topics:

Invoking Your Own Putback Validation Program

This is a sample validation program that you can use to control putbacks to a specific workspace. It can be any executable file (shell script or program) that accepts arguments that are passed by putback and returns non-zero exit status to deny putback.

## Start of sample validation program
#!/bin/sh
##
## Here is the list of users who can do
## putbacks to the workspace
##
valid_users="nikm azv builder vvg aar"
##
## Here is the list of Integration Request IDs (IRIs) which
## are accepted
##
P1Bugs="1111111 2222222 1234567 bobs_bug"
##
## Here are the directories that cannot change
##
DirsReady="doc subdir/doc"
##
## Save arguments
##
User=$1
shift
Parent=$1
shift
Child=$1
shift
IRI=$1
shift
Files=`cat $1`
##
## Validate user
##
isValid="false"
for u in $valid_users
do
if [ "$User" = "$u" ] ; then
isValid="true"
break
fi
done
if [ "$isValid" = "false" ] ; then
# invalid user
echo ""
echo "*** Validation failed: User $User is not allowed \
to putback to $Parent"
echo ""
exit 1
fi
##
## Validate Integration Request ID (IRI)
##
isValid="false"
for u in $P1Bugs
do
if [ "$IRI" = "$u" ] ; then
isValid="true"
break
fi
done
if [ "$isValid" = "false" ] ; then
# invalid IRI
echo ""
echo "*** Validation failed: Integration Request ID $IRI \
is not valid"
echo ""
exit 1
fi
##
## Validate files
##
for u in $Files
do
for uu in $DirsReady
do
x=`echo $u | grep $uu`
if [ "$x" != "" ] ; then
isValid="false"
echo ""
echo "*** Validation failed: File $u \
cannot be changed"
echo ""
exit 1
fi
done
done
##
## Exit 0 - putback is allowed
##
exit 0
## End of sample validation program