#!/bin/sh
# electric commander sets ID_VERSION
if [ -z "$ID_VERSION"]; then
# P4_CHANGELIST is set by a jenkins plugin
if [ -z "$P4_CHANGELIST" ]; then
P4_CHANGELIST=$(p4 changes -m1 @$P4CLIENT | cut -d ' ' -f 2 2> /dev/null)
if [ -z "$P4_CHANGELIST" ]; then
P4_CHANGELIST="SNAPSHOT"
fi
fi
# ID_PATCH is what we use
if [ -z "$ID_PATCH" ]; then
ID_PATCH=$P4_CHANGELIST
fi
# ID_REL_BASE is set in the jenkins job
if [ -z "$ID_REL_BASE" ]; then
ID_REL_BASE=2013.1
fi
# ID_REL_QUALIFIER is set in the jenkins job (or not, it's optional)
# finally, the ID_VERSION
export ID_VERSION=${ID_REL_BASE}.${ID_PATCH}${ID_REL_QUALIFIER:+-${ID_REL_QUALIFIER}}
fi
echo $ID_VERSION