[DEV] add build ID

This commit is contained in:
Edouard DUPIN 2015-10-29 21:21:02 +01:00
parent 76459a38b2
commit 7af54c4f13
2 changed files with 30 additions and 10 deletions

View File

@ -13,6 +13,9 @@ if (isset($_POST['REPO']) == FALSE) {
if (isset($_POST['TAG']) == FALSE) {
die("[ERROR] Missing POST : 'TAG'");
}
if (isset($_POST['ID']) == FALSE) {
die("[ERROR] Missing POST : 'ID'");
}
if (isset($_POST['STATUS']) == FALSE) {
die("[ERROR] Missing POST : 'STATUS'");
}
@ -104,8 +107,9 @@ if ($idGroup <= -1) {
if ( $result == NULL
|| $result->num_rows == 0) {
// simply insert:
$sql = " INSERT INTO `BUILD_snapshot` (`id-group`, `".$_POST['TAG']."`)"
." VALUES ('".$idGroup."',"
$sql = " INSERT INTO `BUILD_snapshot` (`id-build`, `id-group`, `".$_POST['TAG']."`)"
." VALUES ('".$_POST['ID']."',"
." '".$idGroup."',"
." '".$_POST['STATUS']."')";
$result = $COVERAGE_bdd->query($sql);
if ($result == TRUE) {

View File

@ -25,6 +25,8 @@ parser.add_argument("-t", "--tag", help="Tag to register the system 'Linux',
default="")
parser.add_argument("-S", "--status", help="Build status 'START', 'OK', 'ERROR' or $?",
default="")
parser.add_argument("-i", "--id", help="build ID (auto get env variable TRAVIS_BUILD_NUMBER)",
default="")
###################
## Choice 3 ##
###################
@ -32,6 +34,13 @@ parser.add_argument("--test", help="test value (local server ...)",
action="store_true")
args = parser.parse_args()
if args.status not in ['START', 'OK', 'ERROR']:
#print("ploppp : '" + str(args.status) + "'")
if args.status == "0":
args.status = 'OK'
else:
args.status = 'ERROR'
if args.test == True:
args.url = 'http://127.0.0.1/build/inject.php'
args.repo = 'HeeroYui/test'
@ -42,6 +51,9 @@ if args.test == True:
else:
if args.tag == "":
print("[NOTE] (local) not set '--tag' parameter ==> just stop")
if args.status == 'ERROR':
print("[NOTE] build error, stop travis ...")
exit(-3)
exit(0)
list_tag = ['Linux', 'MacOs', 'Windows', 'IOs', 'Android', 'Mingw']
if args.tag not in list_tag:
@ -51,13 +63,6 @@ else:
print("[ERROR] (local) set '--status' parameter")
exit(-2)
if args.status not in ['START', 'OK', 'ERROR']:
#print("ploppp : '" + str(args.status) + "'")
if args.status == "0":
args.status = 'OK'
else:
args.status = 'ERROR'
# todo : check if repo is contituated with a "/" ...
# if repo, sha1 and branch is not set, we try to get it with travis global environement variable :
if args.repo == "":
@ -75,18 +80,25 @@ if args.branch == "":
if args.branch == None:
args.branch = ""
if args.id == "":
args.id = os.environ.get('TRAVIS_BUILD_NUMBER')
if args.id == None:
args.id = ""
print(" url = " + args.url)
print(" repo = " + args.repo)
print(" sha1 = " + args.sha1)
print(" branch = " + args.branch)
print(" tag = " + args.tag)
print(" status = " + args.status)
print(" build id = " + args.id)
data = urllib.urlencode({'REPO':args.repo,
'SHA1':args.sha1,
'LIB_BRANCH':args.branch,
'TAG':args.tag,
'STATUS':args.status})
'STATUS':args.status,
'ID':args.id})
req = urllib2.Request(args.url, data)
response = urllib2.urlopen(req)
@ -97,5 +109,9 @@ print return_data
if return_data[:7] == "[ERROR]":
exit(-1)
if args.status == 'ERROR':
print("[NOTE] build error, stop travis ...")
exit(-3)
exit(0)