Replace usage of "node" by a custom step "machine"

The node step does not output any information about the actual node,
we have to go deep in the menu of Jenkins to find out which machine was
selected.

Change-Id: Ib8c1c6ea1f0d723f08a58e06d5af7029c8e28b6d
diff --git a/jenkins/jobs/global.groovy b/jenkins/jobs/global.groovy
index 78e9211..1825d72 100644
--- a/jenkins/jobs/global.groovy
+++ b/jenkins/jobs/global.groovy
@@ -34,7 +34,7 @@
   // Some basic tests
   // TODO(dmarting): maybe we want to run it in parallel of other jobs?
   stage("Test that all sources are in the //:srcs filegroup") {
-    node("linux-x86_64") {
+    machine("linux-x86_64") {
       recursiveGit(repository: "https://bazel.googlesource.com/bazel",
                    refspec: params.REFSPEC,
                    branch: params.BRANCH)
@@ -48,7 +48,7 @@
 // Deployment steps
 if(params.BRANCH.matches('^(.*/)master$')) {
   stage("Push website") {
-    node("deploy") {
+    machine("deploy") {
       recursiveGit(repository: "https://bazel.googlesource.com/bazel",
                    refspec: params.REFSPEC,
                    branch: params.BRANCH)
@@ -66,7 +66,7 @@
   }
 } else if(params.BRANCH.matches('^refs/((heads/release-)|(tags/)).*$')) {
   def r_name = ""
-  node("deploy") {
+  machine("deploy") {
     r_name = sh(script: "bash -c 'source scripts/release/common.sh; get_full_release_name'",
                 returnStdout: true)
     if (!r_name.isEmpty()) {
diff --git a/jenkins/lib/vars/bazelCiJob.groovy b/jenkins/lib/vars/bazelCiJob.groovy
index e189c1b..1d08f84 100644
--- a/jenkins/lib/vars/bazelCiJob.groovy
+++ b/jenkins/lib/vars/bazelCiJob.groovy
@@ -69,7 +69,7 @@
     "--build_tests_only",
     "-k"
   ]
-  node(config.node_label) {
+  machine(config.node_label) {
     ws("workspace/${currentBuild.fullProjectName}-" +
        config.get("name", config.node_label + "-" + config.bazel_version)) {
       maybeSauce(config.sauce) {
diff --git a/jenkins/lib/vars/bootstrapBazel.groovy b/jenkins/lib/vars/bootstrapBazel.groovy
index d491821..fe5950a 100644
--- a/jenkins/lib/vars/bootstrapBazel.groovy
+++ b/jenkins/lib/vars/bootstrapBazel.groovy
@@ -32,7 +32,7 @@
   def refspec = config.get("refspec", "+refs/heads/*:refs/remotes/origin/*")
   def targets = config.get("targets", [])
 
-  node(config.node) {
+  machine(config.node) {
     def utils = new BazelUtils()
     def release_name = ""
     def isWindows = !isUnix()
diff --git a/jenkins/lib/vars/machine.groovy b/jenkins/lib/vars/machine.groovy
new file mode 100644
index 0000000..d9a64fe
--- /dev/null
+++ b/jenkins/lib/vars/machine.groovy
@@ -0,0 +1,26 @@
+// Copyright (C) 2017 The Bazel Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * Define a step "machine" that wrap the "node" step but adding a line showing information
+ * about the node it is being executed on.
+ */
+def call(String node_label, Closure body) {
+  node(node_label) {
+    stage("Node information") {
+      echo "node = ${env.NODE_NAME}\nworkspace = ${pwd()}"
+    }
+    body()
+  }
+}