Merge "Add artifacts to MQTT reporter"
This commit is contained in:
commit
79d123cbc2
|
@ -128,6 +128,26 @@ An MQTT report uses this schema:
|
||||||
|
|
||||||
The build results (not present in start report).
|
The build results (not present in start report).
|
||||||
|
|
||||||
|
.. attr:: artifacts
|
||||||
|
:type: list
|
||||||
|
|
||||||
|
The build artifacts (not present in start report).
|
||||||
|
|
||||||
|
This is a list of dictionaries corresponding to the returned artifacts.
|
||||||
|
|
||||||
|
.. attr:: name
|
||||||
|
|
||||||
|
The name of the artifact.
|
||||||
|
|
||||||
|
.. attr:: url
|
||||||
|
|
||||||
|
The url of the artifact.
|
||||||
|
|
||||||
|
.. attr:: metadata
|
||||||
|
:type: dict
|
||||||
|
|
||||||
|
The metadata of the artifact. This is a dictionary of
|
||||||
|
arbitrary key values determined by the job.
|
||||||
|
|
||||||
Here is an example of a start message:
|
Here is an example of a start message:
|
||||||
|
|
||||||
|
@ -191,7 +211,8 @@ Here is an example of a success message:
|
||||||
'log_url': 'https://logs.example.com/logs/3/3/1/check/linters/16e3e55/',
|
'log_url': 'https://logs.example.com/logs/3/3/1/check/linters/16e3e55/',
|
||||||
'web_url': 'https://tenant.example.com/t/tenant-one/build/16e3e55aca984c6c9a50cc3c5b21bb83/',
|
'web_url': 'https://tenant.example.com/t/tenant-one/build/16e3e55aca984c6c9a50cc3c5b21bb83/',
|
||||||
'result': 'SUCCESS',
|
'result': 'SUCCESS',
|
||||||
'dependencies': []
|
'dependencies': [],
|
||||||
|
'artifacts': [],
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The MQTT reporter now includes artifact information along with build results.
|
|
@ -586,8 +586,15 @@ class TestMQTTConnection(ZuulTestCase):
|
||||||
"Test the MQTT reporter"
|
"Test the MQTT reporter"
|
||||||
# Add a success result
|
# Add a success result
|
||||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
||||||
|
artifact = {'name': 'image',
|
||||||
|
'url': 'http://example.com/image',
|
||||||
|
'metadata': {
|
||||||
|
'type': 'container_image'
|
||||||
|
}}
|
||||||
self.executor_server.returnData(
|
self.executor_server.returnData(
|
||||||
"test", A, {"zuul": {"log_url": "some-log-url"}}
|
"test", A, {"zuul": {"log_url": "some-log-url",
|
||||||
|
'artifacts': [artifact],
|
||||||
|
}}
|
||||||
)
|
)
|
||||||
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
|
||||||
self.waitUntilSettled()
|
self.waitUntilSettled()
|
||||||
|
@ -606,6 +613,7 @@ class TestMQTTConnection(ZuulTestCase):
|
||||||
self.assertEquals(mqtt_payload['buildset']['builds'][0]['job_name'],
|
self.assertEquals(mqtt_payload['buildset']['builds'][0]['job_name'],
|
||||||
'test')
|
'test')
|
||||||
self.assertNotIn('result', mqtt_payload['buildset']['builds'][0])
|
self.assertNotIn('result', mqtt_payload['buildset']['builds'][0])
|
||||||
|
self.assertNotIn('artifacts', mqtt_payload['buildset']['builds'][0])
|
||||||
|
|
||||||
self.assertEquals(success_event.get('topic'),
|
self.assertEquals(success_event.get('topic'),
|
||||||
'tenant-one/zuul_buildset/check/org/project/master')
|
'tenant-one/zuul_buildset/check/org/project/master')
|
||||||
|
@ -621,6 +629,7 @@ class TestMQTTConnection(ZuulTestCase):
|
||||||
self.assertEquals(test_job['job_name'], 'test')
|
self.assertEquals(test_job['job_name'], 'test')
|
||||||
self.assertEquals(test_job['result'], 'SUCCESS')
|
self.assertEquals(test_job['result'], 'SUCCESS')
|
||||||
self.assertEquals(test_job['dependencies'], [])
|
self.assertEquals(test_job['dependencies'], [])
|
||||||
|
self.assertEquals(test_job['artifacts'], [artifact])
|
||||||
# Both log- and web-url should point to the same URL which is specified
|
# Both log- and web-url should point to the same URL which is specified
|
||||||
# in the build result data under zuul.log_url.
|
# in the build result data under zuul.log_url.
|
||||||
self.assertEquals(test_job['log_url'], 'some-log-url/')
|
self.assertEquals(test_job['log_url'], 'some-log-url/')
|
||||||
|
|
|
@ -17,6 +17,7 @@ import time
|
||||||
import voluptuous as v
|
import voluptuous as v
|
||||||
|
|
||||||
from zuul.lib.logutil import get_annotated_logger
|
from zuul.lib.logutil import get_annotated_logger
|
||||||
|
from zuul.lib.result_data import get_artifacts_from_result_data
|
||||||
from zuul.reporter import BaseReporter
|
from zuul.reporter import BaseReporter
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +74,10 @@ class MQTTReporter(BaseReporter):
|
||||||
'web_url': web_url,
|
'web_url': web_url,
|
||||||
'result': result,
|
'result': result,
|
||||||
'dependencies': [j.name for j in job.dependencies],
|
'dependencies': [j.name for j in job.dependencies],
|
||||||
|
'artifacts': get_artifacts_from_result_data(
|
||||||
|
build.result_data, logger=log)
|
||||||
})
|
})
|
||||||
|
|
||||||
# Report build data of retried builds if available
|
# Report build data of retried builds if available
|
||||||
retry_builds = item.current_build_set.getRetryBuildsForJob(
|
retry_builds = item.current_build_set.getRetryBuildsForJob(
|
||||||
job.name)
|
job.name)
|
||||||
|
|
Loading…
Reference in New Issue