Merge pull request #127 from bazelbuild/helenalt-ci-doc-update

Update user.md
diff --git a/docs/bazel-monitoring.md b/docs/bazel-monitoring.md
index 2a00bc1..c75b1b0 100644
--- a/docs/bazel-monitoring.md
+++ b/docs/bazel-monitoring.md
@@ -15,6 +15,7 @@
 
     -   [bazel-tests](http://ci.bazel.io/job/bazel-tests)
     -   [bazel-slow-tests](http://ci.bazel.io/job/bazel-slow-tests)
+    -   [bazel-remote-tests](http://ci.bazel.io/job/bazel-remote-tests)
     -   [Tutorial](http://ci.bazel.io/job/Tutorial)
     -   [benchmark](http://ci.bazel.io/job/benchmark)
     -   [nightly](http://ci.bazel.io/job/bazel/job/nightly)
diff --git a/gce/linux-android.sh b/gce/linux-android.sh
index 4d3e913..1fe453e 100644
--- a/gce/linux-android.sh
+++ b/gce/linux-android.sh
@@ -38,7 +38,18 @@
     eof
 }
 '
-tools/bin/sdkmanager "platforms;android-24" "platform-tools" \
-  "build-tools;24.0.3" "build-tools;26.0.1" \
-  "add-ons;addon-google_apis-google-24" "extras;android;m2repository"
+
+# platform-tools is necessary for ADB. build-tools 26.0.1 is the oldest version
+# that Bazel supports as of 0.5.4 and is necessary for aapt, dx, apksigner, etc.
+# platforms 24, 25 and 26 are installed in case any future test is written that
+# specifically relies on one of them. extras;android;m2repository is necessary
+# for tests of our support library integration.
+# This should be kept in sync with mac/mac-android.sh.
+tools/bin/sdkmanager \
+  "platform-tools" \
+  "build-tools;26.0.1" \
+  "platforms;android-24" \
+  "platforms;android-25" \
+  "platforms;android-26" \
+  "extras;android;m2repository"
 chown -R ci /home/ci/android
diff --git a/gce/vm.sh b/gce/vm.sh
index f9cb4fb..acebabe 100755
--- a/gce/vm.sh
+++ b/gce/vm.sh
@@ -375,7 +375,7 @@
     echo " - command can be:" >&2
     echo "    create: create the VM, fails if the VM already exists." >&2
     echo "    delete: delete the VM, fails if the VM does not exists." >&2
-    echo "    reimage: reimage the VM, equivalent to create followed by delete." >&2
+    echo "    reimage: reimage the VM, equivalent to delete followed by create." >&2
     echo "    update_metadata: update the VM metadata, the VM must already exists." >&2
     echo "    start: start the VM, the VM must exists." >&2
     echo "    stop: stop the VM, the VM must exists." >&2
diff --git a/jenkins/config/credentials.xml b/jenkins/config/credentials.xml
index 4794ece..3ab959c 100644
--- a/jenkins/config/credentials.xml
+++ b/jenkins/config/credentials.xml
@@ -20,6 +20,13 @@
           <username>bazel_rules_webtesting</username>

           <apiKey>##SECRET:saucelabs.bazel_rules_webtesting.access_key##</apiKey>

         </hudson.plugins.sauce_ondemand.credentials.SauceCredentials>

+        <org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl plugin="plain-credentials@1.4">

+          <scope>GLOBAL</scope>

+          <id>remote-execution</id>

+          <description>credentials for remote execution</description>

+          <fileName>bazel-public-d5508ebd72fb.json</fileName>

+          <secretBytes>##SECRET:remote-execution-secret-bytes##</secretBytes>

+        </org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl>

       </java.util.concurrent.CopyOnWriteArrayList>

     </entry>

   </domainCredentialsMap>

diff --git a/jenkins/jobs/BUILD b/jenkins/jobs/BUILD
index 29714ec..fab37d4 100644
--- a/jenkins/jobs/BUILD
+++ b/jenkins/jobs/BUILD
@@ -96,6 +96,14 @@
 )
 
 bazel_github_job(
+    name = "bazel-tests-remote",
+    config = ":configs/bazel-tests-remote.json",
+    gerrit_project = "bazel",
+    git_url = "https://bazel.googlesource.com/bazel",
+    project = "bazel",
+)
+
+bazel_github_job(
     name = "bazel-tests",
     config = ":configs/empty.json",
     gerrit_project = "bazel",
diff --git a/jenkins/jobs/configs/bazel-tests-remote.json b/jenkins/jobs/configs/bazel-tests-remote.json
new file mode 100644
index 0000000..c739bac
--- /dev/null
+++ b/jenkins/jobs/configs/bazel-tests-remote.json
@@ -0,0 +1,35 @@
+[
+    {
+        "configurations": [
+            {"node": "ubuntu_16.04-x86_64"}
+        ],
+        "parameters": {
+            "startup_opts": [
+                "--host_jvm_args=-Dbazel.DigestFunction=SHA1"
+            ],
+            "build_opts": [
+                "--remote_cache=remotebuildexecution.googleapis.com",
+                "--remote_executor=remotebuildexecution.googleapis.com",
+                "--remote_instance_name=projects/bazel-public",
+                "--spawn_strategy=remote",
+                "--remote_timeout=3600",
+                "--strategy=Javac=remote",
+                "--strategy=Closure=remote",
+                "--genrule_strategy=remote",
+                "--auth_enabled=true",
+                "--tls_enabled=true",
+                "--jobs=75",
+                "--experimental_strict_action_env=true",
+                "--experimental_remote_platform_override='properties:{ name:\"container-image\" value:\"docker://gcr.io/asci-toolchain/nosla-debian8-clang-fl@sha256:b80da64e2a6f75af122bbb70021ebaab98b073f144ab04653c0de49bd943d8e9\" }'",
+                "--crosstool_top=@bazel_toolchains//configs/debian8_clang/0.1.0/bazel_0.5.4:toolchain",
+                "--host_java_toolchain=@bazel_toolchains//configs/java/0.1.0/bazel_0.5.4:remote_toolchain",
+                "--java_toolchain=@bazel_toolchains//configs/java/0.1.0/bazel_0.5.4:remote_toolchain"
+            ],
+            "tests": [
+                "//src/test/shell/integration/..."
+            ],
+            "test_tag_filters": ["-slow"],
+            "targets": [],
+        },
+    }
+]
diff --git a/jenkins/jobs/configs/tensorflow.json b/jenkins/jobs/configs/tensorflow.json
index fe7f4b7..36cbe51 100644
--- a/jenkins/jobs/configs/tensorflow.json
+++ b/jenkins/jobs/configs/tensorflow.json
@@ -11,7 +11,7 @@
         ],
         "parameters": {
             "configure": [
-                "echo 'import %workspace%/.bazelrc' >>bazel.bazelrc",
+                "echo -e '\nimport %workspace%/.bazelrc' >>bazel.bazelrc",
                 "touch .bazelrc",
                 "./tensorflow/tools/ci_build/builds/configured CPU"
             ],
diff --git a/jenkins/jobs/configs/tensorflow_serving.json b/jenkins/jobs/configs/tensorflow_serving.json
index a29f8e5..bdaa583 100644
--- a/jenkins/jobs/configs/tensorflow_serving.json
+++ b/jenkins/jobs/configs/tensorflow_serving.json
@@ -12,7 +12,7 @@
         "parameters": {
             "configure": [
                 "(cd tensorflow && ./tensorflow/tools/ci_build/builds/configured CPU)",
-                "echo 'import %workspace%/tensorflow/.tf_configure.bazelrc' >>bazel.bazelrc",
+                "echo -e '\nimport %workspace%/tensorflow/.tf_configure.bazelrc' >>bazel.bazelrc",
                 "$BAZEL clean" // Clean to work around bazelbuild/bazel#3664
             ],
             "tests": ["tensorflow_serving/... - //tensorflow_serving/model_servers:tensorflow_model_server_test"],
diff --git a/jenkins/jobs/configs/tf_models_syntaxnet.json b/jenkins/jobs/configs/tf_models_syntaxnet.json
index 0ff303b..1a3660d 100644
--- a/jenkins/jobs/configs/tf_models_syntaxnet.json
+++ b/jenkins/jobs/configs/tf_models_syntaxnet.json
@@ -12,7 +12,7 @@
         "parameters": {
             "configure": [
                 "(cd tensorflow && ./tensorflow/tools/ci_build/builds/configured CPU)",
-                "echo 'import %workspace%/tensorflow/.tf_configure.bazelrc' >>bazel.bazelrc",
+                "echo -e '\nimport %workspace%/tensorflow/.tf_configure.bazelrc' >>bazel.bazelrc",
                 "$BAZEL clean" // Clean to work around bazelbuild/bazel#3664
             ],
             "tests": ["syntaxnet/... - //syntaxnet:beam_reader_ops_test - //syntaxnet:graph_builder_test - //syntaxnet:lexicon_builder_test - //syntaxnet:parser_trainer_test - //syntaxnet:reader_ops_test - //syntaxnet:text_formats_test - //syntaxnet/util:check_test - //syntaxnet/util:registry_test", "util/utf8/..."],
diff --git a/jenkins/lib/vars/bazelJob.groovy b/jenkins/lib/vars/bazelJob.groovy
index 37d4343..1546cc7 100644
--- a/jenkins/lib/vars/bazelJob.groovy
+++ b/jenkins/lib/vars/bazelJob.groovy
@@ -44,30 +44,33 @@
   utils.bazel = config.binary
   utils.script = this;
 
-  // And now the various stage
-  def stage_prefix = config.stage_name.isEmpty() ? "" : "[${config.stage_name}] "
-  utils.writeRc(config.build_opts, config.test_opts, config.startup_opts, config.extra_bazelrc)
-  stage("${stage_prefix}Bazel version") {
-    utils.bazelCommand("version")
-  }
+  withCredentials([file(credentialsId: 'remote-execution', variable: 'AUTH_FILE')]) {
 
-  if(!config.configuration.isEmpty()) {
-    stage("${stage_prefix}Configuration") {
-      utils.commandWithBazelOnPath(config.configuration.join("\n"))
+    // And now the various stage
+    def stage_prefix = config.stage_name.isEmpty() ? "" : "[${config.stage_name}] "
+    utils.writeRc(config.build_opts, config.test_opts, config.startup_opts, config.extra_bazelrc + "\nbuild --auth_credentials=${AUTH_FILE}")
+    stage("${stage_prefix}Bazel version") {
+      utils.bazelCommand("version")
     }
-  }
 
-  stage("${stage_prefix}Build") {
-    utils.build(config.targets)
-  }
-
-  try {
-    stage("${stage_prefix}Tests") {
-      utils.test(config.tests)
+    if(!config.configuration.isEmpty()) {
+      stage("${stage_prefix}Configuration") {
+        utils.commandWithBazelOnPath(config.configuration.join("\n"))
+      }
     }
-  } finally {
-    stage("${stage_prefix}Results") {
-      utils.testlogs("tests-${config.stage_name.replaceAll(',', '-')}")
+
+    stage("${stage_prefix}Build") {
+      utils.build(config.targets)
+    }
+
+    try {
+      stage("${stage_prefix}Tests") {
+        utils.test(config.tests)
+      }
+    } finally {
+      stage("${stage_prefix}Results") {
+        utils.testlogs("tests-${config.stage_name.replaceAll(',', '-')}")
+      }
     }
   }
 }
diff --git a/mac/mac-android.sh b/mac/mac-android.sh
index c1d0b6d..4b29c3c 100644
--- a/mac/mac-android.sh
+++ b/mac/mac-android.sh
@@ -43,6 +43,12 @@
     eof
 }
 '
-tools/bin/sdkmanager "platforms;android-24" "platform-tools" \
-  "build-tools;24.0.3" "build-tools;26.0.1" \
-  "add-ons;addon-google_apis-google-24" "extras;android;m2repository"
+
+# This should be kept in sync with linux/linux-android.sh
+tools/bin/sdkmanager \
+  "platform-tools" \
+  "build-tools;26.0.1" \
+  "platforms;android-24" \
+  "platforms;android-25" \
+  "platforms;android-26" \
+  "extras;android;m2repository"