Skip to content

Commit

Permalink
CI/travis/lib.sh: fix triggering multiple builds
Browse files Browse the repository at this point in the history
Travis CI has multiple job states to account for (queued, received, etc).
In some conditions, the number of created + started == 1, which typically
happens during multiple Travis-CI builds running.

It's also hard to say "job[state] not in [list states]" since there are so
many job states to account for. So we try to account for the ones we could
identify so far.

Travis' API docs are not that great either. They claims it's
self-documenting. Oh well...
Links:
  https://docs.travis-ci.com/user/developer/#api-v3
  https://developer.travis-ci.com/resource/jobs#Jobs

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
  • Loading branch information
commodo committed Apr 11, 2019
1 parent cce2ee2 commit 826563e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CI/travis/jobs_running_cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@

jobs_running = 0
for job in json_r['jobs']:
if (job['state'] in [ 'started', 'created' ]):
# bump number of jobs higher, so nothing triggers
if (job['state'] in [ 'canceled', 'failed' ]):
jobs_running += 99
break
if (job['state'] in [ 'started', 'created', 'queued', 'received' ]):
jobs_running += 1

print (jobs_running)

0 comments on commit 826563e

Please sign in to comment.