[devicelab] Propagate git_url and git_ref to subbuilds.

Also as the swarming url is disallowd on milo, replace it with the milo url.

Bug: https://github.com/flutter/flutter/issues/64346
Test: https://ci.chromium.org/swarming/task/4e2b2305f6db3110?server=chromium-swarm.appspot.com
Change-Id: I9cada20e5199f616165a70f757fc0b5007751660
Fixed: 64346
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/5920
Reviewed-by: Keyong Han <keyonghan@google.com>
Commit-Queue: Tong Wu <wutong@google.com>
diff --git a/recipe_modules/job/api.py b/recipe_modules/job/api.py
index 1f2ab72..c5a382a 100644
--- a/recipe_modules/job/api.py
+++ b/recipe_modules/job/api.py
@@ -90,7 +90,7 @@
     job.task_id = final.launch_result.task_id
     job.task_server = final.launch_result.swarming_hostname
 
-    presentation.links[job.name] = job.task_url
+    presentation.links[job.name] = job.milo_url
     return job
 
   def collect(self, jobs, presentation):
diff --git a/recipe_modules/job/examples/full.expected/launch.json b/recipe_modules/job/examples/full.expected/launch.json
index 42dbac1..9581dda 100644
--- a/recipe_modules/job/examples/full.expected/launch.json
+++ b/recipe_modules/job/examples/full.expected/launch.json
@@ -3,7 +3,7 @@
     "cmd": [],
     "name": "launch job",
     "~followup_annotations": [
-      "@@@STEP_LINK@fake_job0@chromium-swarm.appspot.com/task?id=job_task_id@@@"
+      "@@@STEP_LINK@fake_job0@https://ci.chromium.org/swarming/task/job_task_id?server=chromium-swarm.appspot.com@@@"
     ]
   },
   {
diff --git a/recipe_modules/job/examples/full.py b/recipe_modules/job/examples/full.py
index f54cd54..33a21ae 100644
--- a/recipe_modules/job/examples/full.py
+++ b/recipe_modules/job/examples/full.py
@@ -40,6 +40,7 @@
   elif test_name == "current_recipe":
     api.job.current_recipe()
 
+  job1.task_url # For test coverage.
 
 def GenTests(api):
   yield api.test(
diff --git a/recipes/devicelab.expected/schedule.json b/recipes/devicelab.expected/schedule.json
index 6be6f8e..bb9239a 100644
--- a/recipes/devicelab.expected/schedule.json
+++ b/recipes/devicelab.expected/schedule.json
@@ -190,7 +190,7 @@
     "cmd": [],
     "name": "launch jobs",
     "~followup_annotations": [
-      "@@@STEP_LINK@android_defines_test@chromium-swarm.appspot.com/task?id=fake-task-id@@@"
+      "@@@STEP_LINK@android_defines_test@https://ci.chromium.org/swarming/task/fake-task-id?server=chromium-swarm.appspot.com@@@"
     ]
   },
   {
@@ -248,13 +248,17 @@
       "[CACHE]/led/led",
       "edit",
       "-p",
-      "recipe=\"devicelab\"",
-      "-p",
       "role=\"worker\"",
       "-p",
       "name=\"android_defines_test\"",
       "-p",
+      "git_ref=null",
+      "-p",
       "first_capability=\"linux/android\"",
+      "-p",
+      "recipe=\"devicelab\"",
+      "-p",
+      "git_url=null",
       "-d",
       "cores=",
       "-d",
@@ -280,6 +284,8 @@
       "@@@STEP_LOG_LINE@proto.output@        \"input\": {@@@",
       "@@@STEP_LOG_LINE@proto.output@          \"properties\": {@@@",
       "@@@STEP_LOG_LINE@proto.output@            \"first_capability\": \"linux/android\", @@@",
+      "@@@STEP_LOG_LINE@proto.output@            \"git_ref\": null, @@@",
+      "@@@STEP_LOG_LINE@proto.output@            \"git_url\": null, @@@",
       "@@@STEP_LOG_LINE@proto.output@            \"name\": \"android_defines_test\", @@@",
       "@@@STEP_LOG_LINE@proto.output@            \"recipe\": \"devicelab\", @@@",
       "@@@STEP_LOG_LINE@proto.output@            \"role\": \"worker\"@@@",
@@ -299,7 +305,7 @@
       "-modernize"
     ],
     "name": "launch jobs.led launch",
-    "stdin": "{\n\"buildbucket\": {\n\"bbagent_args\": {\n\"build\": {\n\"builder\": {}, \n\"input\": {\n\"properties\": {\n\"first_capability\": \"linux/android\", \n\"name\": \"android_defines_test\", \n\"recipe\": \"devicelab\", \n\"role\": \"worker\"\n}\n}\n}\n}\n}\n}",
+    "stdin": "{\n\"buildbucket\": {\n\"bbagent_args\": {\n\"build\": {\n\"builder\": {}, \n\"input\": {\n\"properties\": {\n\"first_capability\": \"linux/android\", \n\"git_ref\": null, \n\"git_url\": null, \n\"name\": \"android_defines_test\", \n\"recipe\": \"devicelab\", \n\"role\": \"worker\"\n}\n}\n}\n}\n}\n}",
     "~followup_annotations": [
       "@@@STEP_NEST_LEVEL@1@@@",
       "@@@STEP_LOG_LINE@json.output@{@@@",
diff --git a/recipes/devicelab.py b/recipes/devicelab.py
index 6f6e225..2a716d9 100644
--- a/recipes/devicelab.py
+++ b/recipes/devicelab.py
@@ -61,6 +61,8 @@
             "recipe": api.job.current_recipe(),
             "role": "worker",
             "first_capability": first_capability,
+            "git_url": api.properties.get('git_url'),
+            "git_ref": api.properties.get('git_ref'),
         })
         # TODO(wutong): add a devicelab dedicated builder that would save us
         # from removing extra dimensions like "cores", "os" etc.