Use the pipeline job for the bazel job.

Once submitted we can remove all the code for the legacy "github-jobs".

Fixes #56.
Fixes #89.

Change-Id: I4cb31f2f0296b9d5f98ab04b066feea2df0b3e9f
diff --git a/jenkins/build_defs/bazel-job.xml.tpl b/jenkins/build_defs/bazel-job.xml.tpl
new file mode 100644
index 0000000..b6073d5
--- /dev/null
+++ b/jenkins/build_defs/bazel-job.xml.tpl
@@ -0,0 +1,45 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<flow-definition plugin="workflow-job">
+  <actions/>
+  <description>Test the {{ variables.PROJECT_NAME }} project located at {{ variables.GIT_URL }}.</description>
+  <keepDependencies>false</keepDependencies>
+  <properties>
+    {% if variables.RUN_SEQUENTIAL == "true" %}
+    <org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty/>
+    {% endif %}
+    {% if variables.github == "True" %}
+    <com.coravy.hudson.plugins.github.GithubProjectProperty>
+      <projectUrl>{{ variables.GITHUB_URL }}</projectUrl>
+    </com.coravy.hudson.plugins.github.GithubProjectProperty>
+    {% endif %}
+    <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
+      <triggers>
+        {% if variables.enable_trigger == "true" %}
+        <com.cloudbees.jenkins.GitHubPushTrigger>
+          <spec></spec>
+        </com.cloudbees.jenkins.GitHubPushTrigger>
+        {% endif %}
+      </triggers>
+    </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
+  </properties>
+  <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps">
+    <script><![CDATA[
+bazelCiConfiguredJob(
+    repository: "{{ variables.GIT_URL }}",
+    branch: "{{ variables.BRANCH }}",
+    bazel_version: "latest",
+    configuration: '''{{ raw_imports['JSON_CONFIGURATION'].replace('\\', '\\\\').replace("'", "\\'") }}''',
+    workspace: "{{ variables.WORKSPACE }}",
+    mail_recipient: "{{ variables.BAZEL_BUILD_RECIPIENT }}",
+    {% if variables.SAUCE_ENABLED == "true" %}
+    sauce: "61b4846b-279d-4369-ae20-31e9d8b9bc66",
+    {% endif %}
+    run_sequentially: {{ variables.RUN_SEQUENTIAL }},
+    restrict_configuration: {{ variables.RESTRICT_CONFIGURATION }}
+)
+    ]]></script>
+    <sandbox>true</sandbox>
+  </definition>
+  <triggers/>
+  <quietPeriod>5</quietPeriod>
+</flow-definition>
diff --git a/jenkins/build_defs/jenkins_job.bzl b/jenkins/build_defs/jenkins_job.bzl
index dc4c2e1..7ac7f4c 100644
--- a/jenkins/build_defs/jenkins_job.bzl
+++ b/jenkins/build_defs/jenkins_job.bzl
@@ -166,13 +166,10 @@
 
   jenkins_job(
       name = name,
-      config = "//jenkins/build_defs:github-jobs.xml.tpl",
-      deps = [
-          "//jenkins/build_defs:github-jobs.sh.tpl",
-          "//jenkins/build_defs:github-jobs.bat.tpl",
-          "//jenkins/build_defs:github-jobs.test-logs.sh.tpl",
-          "//jenkins/build_defs:github-jobs.test-logs.bat.tpl",
-      ],
+      config = "//jenkins/build_defs:bazel-job.xml.tpl",
+      deps_aliases = {
+        "JSON_CONFIGURATION": config,
+      },
       substitutions=substitutions,
       git_url=git_url,
       project=project,
diff --git a/jenkins/jobs/BUILD b/jenkins/jobs/BUILD
index 8cdefe6..3f43535 100644
--- a/jenkins/jobs/BUILD
+++ b/jenkins/jobs/BUILD
@@ -324,35 +324,6 @@
 )
 
 bazel_github_job(
-    name = "intellij-android-studio",
-    build_opts = ["--define=ij_product=android-studio-latest"],
-    # All config of Intellij are tested by the intellij job now
-    config = "",
-    enabled = False,
-    org = "bazelbuild",
-    platforms = UNIX_PLATFORMS,
-    project = "intellij",
-    project_url = "https://ij.bazel.io",
-    targets = ["aswb:aswb_bazel"],
-    test_opts = ["--define=ij_product=android-studio-latest"],
-    tests = [":aswb_tests"],
-)
-
-bazel_github_job(
-    name = "intellij-clion",
-    build_opts = ["--define=ij_product=clion-latest"],
-    # All config of Intellij are tested by the intellij job now
-    config = "",
-    org = "bazelbuild",
-    platforms = UNIX_PLATFORMS,
-    project = "intellij",
-    project_url = "https://ij.bazel.io",
-    targets = ["clwb:clwb_bazel"],
-    test_opts = ["--define=ij_product=clion-latest"],
-    tests = [":clwb_tests"],
-)
-
-bazel_github_job(
     name = "migration-tooling",
     org = "bazelbuild",
     platforms = UNIX_PLATFORMS,
diff --git a/jenkins/jobs/jobs.bzl b/jenkins/jobs/jobs.bzl
index 7a3fce7..fa09a2d 100644
--- a/jenkins/jobs/jobs.bzl
+++ b/jenkins/jobs/jobs.bzl
@@ -50,8 +50,6 @@
     # for the job to keep history but use the new project name.
     "rules_web",
     "intellij",
-    "intellij-android-studio",
-    "intellij-clion",
     "buildifier",
     "rules_jsonnet",
     "rules_rust",