Browse Source

Merge "Fix log_url parsing for new job types"

changes/83/303583/1
Jenkins 3 years ago
parent
commit
224ed54b1e
1 changed files with 11 additions and 1 deletions
  1. 11
    1
      files/subunit-gearman-worker.py

+ 11
- 1
files/subunit-gearman-worker.py View File

@@ -180,7 +180,17 @@ class Subunit2SQLProcessor(object):
180 180
         # Set run metadata from gearman
181 181
         log_url = subunit.pop('log_url', None)
182 182
         if log_url:
183
-            log_dir = os.path.dirname(os.path.dirname(log_url))
183
+            log_dir = os.path.dirname(log_url)
184
+
185
+            # log_dir should be the top-level directory containing a job run,
186
+            # but the subunit file may be nested in 0 - 2 subdirectories (top,
187
+            # logs/, or logs/old/), so we need to safely correct the path here
188
+            log_base = os.path.basename(log_dir)
189
+            if log_base == 'logs':
190
+                log_dir = os.path.dirname(log_dir)
191
+            elif log_base == 'old':
192
+                log_dir = os.path.dirname(os.path.dirname(log_dir))
193
+
184 194
             shell.CONF.set_override('artifacts', log_dir)
185 195
         shell.CONF.set_override('run_meta', subunit)
186 196
         # Parse subunit stream and store in DB

Loading…
Cancel
Save