diff --git a/git_cl.py b/git_cl.py index e0c82572c..b41a5ee88 100755 --- a/git_cl.py +++ b/git_cl.py @@ -528,6 +528,14 @@ def _make_try_job_schedule_requests(changelist, buckets, options, patchset): ] + shared_tags, } }) + + if options.revision: + requests[-1]['scheduleBuild']['gitilesCommit'] = { + 'host': gerrit_changes[0]['host'], + 'project': gerrit_changes[0]['project'], + 'id': options.revision + } + return requests diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 67792a91f..e9d28b54f 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -3303,6 +3303,83 @@ class CMDTryTestCase(CMDTestCaseBase): mockCallBuildbucket.assert_called_with( mock.ANY, 'cr-buildbucket.appspot.com', 'Batch', expected_request) + @mock.patch('git_cl._call_buildbucket') + def testScheduleOnBuildbucketWithRevision(self, mockCallBuildbucket): + mockCallBuildbucket.return_value = {} + + self.assertEqual(0, git_cl.main([ + 'try', '-B', 'luci.chromium.try', '-b', 'win', '-b', 'linux', + '-p', 'key=val', '-p', 'json=[{"a":1}, null]', + '-r', 'beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeef'])) + self.assertIn( + 'Scheduling jobs on:\nBucket: luci.chromium.try', + git_cl.sys.stdout.getvalue()) + + expected_request = { + "requests": [{ + "scheduleBuild": { + "requestId": "uuid4", + "builder": { + "project": "chromium", + "builder": "linux", + "bucket": "try", + }, + "gerritChanges": [{ + "project": "depot_tools", + "host": "chromium-review.googlesource.com", + "patchset": 7, + "change": 123456, + }], + "properties": { + "category": "git_cl_try", + "json": [{"a": 1}, None], + "key": "val", + }, + "tags": [ + {"value": "linux", "key": "builder"}, + {"value": "git_cl_try", "key": "user_agent"}, + ], + "gitilesCommit": { + "host": "chromium-review.googlesource.com", + "project": "depot_tools", + "id": "beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeef", + } + }, + }, + { + "scheduleBuild": { + "requestId": "uuid4", + "builder": { + "project": "chromium", + "builder": "win", + "bucket": "try", + }, + "gerritChanges": [{ + "project": "depot_tools", + "host": "chromium-review.googlesource.com", + "patchset": 7, + "change": 123456, + }], + "properties": { + "category": "git_cl_try", + "json": [{"a": 1}, None], + "key": "val", + }, + "tags": [ + {"value": "win", "key": "builder"}, + {"value": "git_cl_try", "key": "user_agent"}, + ], + "gitilesCommit": { + "host": "chromium-review.googlesource.com", + "project": "depot_tools", + "id": "beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeef", + } + }, + }], + } + mockCallBuildbucket.assert_called_with( + mock.ANY, 'cr-buildbucket.appspot.com', 'Batch', expected_request) + def testScheduleOnBuildbucket_WrongBucket(self): self.assertEqual(0, git_cl.main([ 'try', '-B', 'not-a-bucket', '-b', 'win',