Allow jjb job to run a bootstrap
Normally this is geared up to only run changes. Allow this to run on
instance startup to initialize jobs.
Change-Id: I9d850333e7896ba81e41043cf1f64454197df202
Signed-off-by: Dean Birch <dean.birch@arm.com>
diff --git a/ci/run-jjb.py b/ci/run-jjb.py
index 7fba293..e669c0d 100755
--- a/ci/run-jjb.py
+++ b/ci/run-jjb.py
@@ -1,5 +1,6 @@
#!/usr/bin/python3
+import glob
import os
import shutil
import signal
@@ -43,7 +44,7 @@
'[jenkins]\n'
'user=%s\n'
'password=%s\n'
- 'url=https://ci.trustedfirmware.org/\n' % (jjb_user, jjb_password))
+ 'url=%s\n' % (jjb_user, jjb_password, jenkins_url))
with open('jenkins_jobs.ini', 'w') as f:
f.write(jenkins_jobs_ini)
jjb_args.append('--conf=jenkins_jobs.ini')
@@ -62,45 +63,52 @@
# Dry-run, don't delete jobs.
jjb_delete_args.insert(0, 'echo')
-try:
- git_args = ['git', 'diff', '--raw',
- os.environ.get('GIT_PREVIOUS_COMMIT'),
- os.environ.get('GIT_COMMIT')]
- proc = subprocess.run(git_args, capture_output=True)
-except (OSError, ValueError) as e:
- raise ValueError("%s" % e)
+if not os.environ.get('JJB_BOOTSTRAP', False):
+ try:
+ git_args = ['git', 'diff', '--raw',
+ os.environ.get('GIT_PREVIOUS_COMMIT'),
+ os.environ.get('GIT_COMMIT')]
+ proc = subprocess.run(git_args, capture_output=True)
+ except (OSError, ValueError) as e:
+ raise ValueError("%s" % e)
+
+ data = proc.stdout.decode()
+ if proc.returncode != 0:
+ raise ValueError("command has failed with code '%s'" % proc.returncode)
-data = proc.stdout.decode()
-if proc.returncode != 0:
- raise ValueError("command has failed with code '%s'" % proc.returncode)
filelist = []
deletelist = []
files = []
-for line in data.splitlines():
- # Format of the git-diff; we only need OPERATION and FILE1
- #
- # :<OLD MODE> <NEW MODE> <OLD REF> <NEW REF> <OPERATION> <FILE1> <FILE2>
- elems = line.split()
- operation = elems[4][0]
- filename = elems[5]
-
- if filename.endswith('.yaml') and '/' not in filename:
- # No point trying to test deleted jobs because they don't exist any
- # more.
- if operation == 'D':
- deletelist.append(filename[:-5])
- continue
- # operation R100 is 100% rename, which means sixth element is the renamed file
- if operation == 'R':
- filename = elems[6]
- # delete old job name
- deletelist.append(elems[5][:-5])
- filelist.append(filename)
- else:
- files = findparentfiles(filename)
- for tempname in files:
- filelist.append(tempname)
+if not os.environ.get('JJB_BOOTSTRAP', False):
+ for line in data.splitlines():
+ # Format of the git-diff; we only need OPERATION and FILE1
+ #
+ # :<OLD MODE> <NEW MODE> <OLD REF> <NEW REF> <OPERATION> <FILE1> <FILE2>
+ elems = line.split()
+ operation = elems[4][0]
+ filename = elems[5]
+
+ if filename.endswith('.yaml') and '/' not in filename:
+ # No point trying to test deleted jobs because they don't exist any
+ # more.
+ if operation == 'D':
+ deletelist.append(filename[:-5])
+ continue
+ # operation R100 is 100% rename, which means sixth element is the renamed file
+ if operation == 'R':
+ filename = elems[6]
+ # delete old job name
+ deletelist.append(elems[5][:-5])
+ filelist.append(filename)
+ else:
+ files = findparentfiles(filename)
+ for tempname in files:
+ filelist.append(tempname)
+else:
+ print(f"As JJB_BOOTSTRAP is set, finding yaml definitions from {os.getcwd()}")
+ for file in glob.glob("./*.yaml"):
+ filelist.append(file.replace("./", ""))
# Remove duplicate entries in the list
filelist = list(set(filelist))