1
0
mirror of https://github.com/Adam-Ant/drone-trigger synced 2024-12-20 07:24:34 +00:00

Fixes to make the build process work

This commit is contained in:
Adam Dodman 2017-07-17 18:02:28 +01:00
parent bb0721b645
commit 5698858e5c

View File

@ -41,11 +41,11 @@ auth_key = eyJEXAMPLE.AUTH.KEY
def runbuild(repo: str, branch: str): def runbuild(repo: str, branch: str):
url = drone_host + '/api/repos/' + repo url = drone_host + '/api/repos/' + repo
latest = jload(requests.get(url + '/builds/latest', headers={'Authorization': auth}).text) latest = jload(requests.get(url + '/builds/latest', headers={'Authorization': drone_auth_key}).text)
build_num = False build_num = False
if (latest['branch'] != branch): if (latest['branch'] != branch):
while not build_num: while not build_num:
latest = jload(requests.get(url + '/builds/' + str(latest['number'] - 1), headers={'Authorization': auth}).text) latest = jload(requests.get(url + '/builds/' + str(latest['number'] - 1), headers={'Authorization': drone_auth_key}).text)
if (latest['branch'] == branch): if (latest['branch'] == branch):
build_num = str(latest['number']) build_num = str(latest['number'])
else: else:
@ -134,7 +134,7 @@ if __name__ == '__main__':
r.raise_for_status() r.raise_for_status()
new_value = jsonVal(r.text, config[service].get('structure')) new_value = jsonVal(r.text, config[service].get('structure'))
if (new_value != config[service]['current_value']): if (new_value != config[service]['current_value']):
print(date.strftime("%d/%m/%Y %H:%M:%S") + ': Got new build - ' + new_value) print(time.strftime("%d/%m/%Y %H:%M:%S") + ': Got new build - ' + new_value)
if not (config[service].get('branch', False)): if not (config[service].get('branch', False)):
branch = 'master' branch = 'master'
else: else:
@ -142,7 +142,7 @@ if __name__ == '__main__':
if (runbuild(config[service].get('drone_repo'), branch)): if (runbuild(config[service].get('drone_repo'), branch)):
config[service]['current_value'] = new_value config[service]['current_value'] = new_value
with open(filepath + '/dronetrigger.cfg', 'w') as configfile: with open(filepath + '/dronetrigger.cfg', 'w') as configfile:
config.write(configfile) config.write()
print("Successfully build new version for " + service) print("Successfully build new version for " + service)
except: except: