Move credentials-id at SCM/origin level

Even though Jenkins Job Builder supports the credentials-id
at both SCM and Source level, it would ignore the ones at SCM
level if there is a "sources" array defined.

Unfortunately that isn't detected by the Jenkins Job Builder
at all and just results in the configuration of SCM sources
without any credentials-id, which would result in a broken
job definition.

Move all the credentials-id definition at source level, when
present, so that the credentials are set as expected in all
jobs definition.

TODO: Jenkins job builder needs fixing in both documentation
and implementation.

Change-Id: Ia10bcb4a6a8bdd5962450669ac567c7d1625b884
diff --git a/jenkins/gerrit-app-analytics-etl.yaml b/jenkins/gerrit-app-analytics-etl.yaml
index e456afb..46f4f7d 100644
--- a/jenkins/gerrit-app-analytics-etl.yaml
+++ b/jenkins/gerrit-app-analytics-etl.yaml
@@ -24,10 +24,10 @@
             - job-extended-read
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/apps/{name}
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule:
diff --git a/jenkins/gerrit-bazel-plugin-account.yaml b/jenkins/gerrit-bazel-plugin-account.yaml
index a34139b..9645827 100644
--- a/jenkins/gerrit-bazel-plugin-account.yaml
+++ b/jenkins/gerrit-bazel-plugin-account.yaml
@@ -7,10 +7,10 @@
     project-name: plugins%2Faccount
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
           branches:
diff --git a/jenkins/gerrit-bazel-plugin-examples.yaml b/jenkins/gerrit-bazel-plugin-examples.yaml
index 76d4286..1c9f1b6 100644
--- a/jenkins/gerrit-bazel-plugin-examples.yaml
+++ b/jenkins/gerrit-bazel-plugin-examples.yaml
@@ -5,10 +5,10 @@
     targets: ''
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/examples
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           skip-tag: true
diff --git a/jenkins/gerrit-bazel-plugin-gitblit.yaml b/jenkins/gerrit-bazel-plugin-gitblit.yaml
index 472d83d..ae996d8 100644
--- a/jenkins/gerrit-bazel-plugin-gitblit.yaml
+++ b/jenkins/gerrit-bazel-plugin-gitblit.yaml
@@ -21,14 +21,16 @@
             - job-extended-read
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/gitblit
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
             - gitblit:
                 url: https://gerrit.googlesource.com/a/gitblit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule:
@@ -47,14 +49,16 @@
     node: bazel-debian
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/gitblit
+                credentials-id: gerrit.googlesource.com
             - gitblit:
                 url: https://gerrit.googlesource.com/a/gitblit
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule:
diff --git a/jenkins/gerrit-bazel-plugin-its-template.yaml b/jenkins/gerrit-bazel-plugin-its-template.yaml
index b85699d..88f62a0 100644
--- a/jenkins/gerrit-bazel-plugin-its-template.yaml
+++ b/jenkins/gerrit-bazel-plugin-its-template.yaml
@@ -22,14 +22,16 @@
             - job-extended-read
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - plugin:
                 url: https://gerrit.googlesource.com/a/plugins/its-{name}
+                credentials-id: gerrit.googlesource.com
             - origin:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
             - base:
                 url: https://gerrit.googlesource.com/a/plugins/its-base
+                credentials-id: gerrit.googlesource.com
           branches:
             - plugin/{branch}
           submodule:
@@ -62,12 +64,13 @@
     node: bazel-debian
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - plugin:
                 url: https://gerrit.googlesource.com/a/plugins/its-{name}
+                credentials-id: gerrit.googlesource.com
             - base:
                 url: https://gerrit.googlesource.com/a/plugins/its-base
+                credentials-id: gerrit.googlesource.com
           branches:
             - plugin/{branch}
           skip-tag: true
diff --git a/jenkins/gerrit-bazel-plugin-javamelody.yaml b/jenkins/gerrit-bazel-plugin-javamelody.yaml
index acfb03f..9a1321f 100644
--- a/jenkins/gerrit-bazel-plugin-javamelody.yaml
+++ b/jenkins/gerrit-bazel-plugin-javamelody.yaml
@@ -4,12 +4,13 @@
     defaults: plugin-template-bazel
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule:
diff --git a/jenkins/gerrit-bazel-plugin-manual-template.yaml b/jenkins/gerrit-bazel-plugin-manual-template.yaml
index efe07d1..a6d5c9d 100644
--- a/jenkins/gerrit-bazel-plugin-manual-template.yaml
+++ b/jenkins/gerrit-bazel-plugin-manual-template.yaml
@@ -31,12 +31,13 @@
           override-build-parameters: true
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
         branches:
           - origin/{branch}
         submodule:
diff --git a/jenkins/gerrit-bazel-plugin-owners.yaml b/jenkins/gerrit-bazel-plugin-owners.yaml
index 030ea88..207a400 100644
--- a/jenkins/gerrit-bazel-plugin-owners.yaml
+++ b/jenkins/gerrit-bazel-plugin-owners.yaml
@@ -4,12 +4,13 @@
     defaults: plugin-template-bazel
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule:
@@ -31,12 +32,13 @@
     defaults: plugin-template-bazel
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule:
diff --git a/jenkins/gerrit-bazel-plugin-scripting-template.yaml b/jenkins/gerrit-bazel-plugin-scripting-template.yaml
index 197066f..b879f0a 100644
--- a/jenkins/gerrit-bazel-plugin-scripting-template.yaml
+++ b/jenkins/gerrit-bazel-plugin-scripting-template.yaml
@@ -22,12 +22,13 @@
             - job-extended-read
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/scripting/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule:
@@ -43,12 +44,13 @@
     defaults: plugin-scripting-template
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/scripting/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           skip-tag: true
@@ -67,10 +69,10 @@
     defaults: plugin-scripting-template
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/scripting/{name}
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           skip-tag: true
diff --git a/jenkins/gerrit-bazel-plugin-template.yaml b/jenkins/gerrit-bazel-plugin-template.yaml
index 939a733..e1986ce 100644
--- a/jenkins/gerrit-bazel-plugin-template.yaml
+++ b/jenkins/gerrit-bazel-plugin-template.yaml
@@ -56,12 +56,13 @@
     project-name: plugins%2F{name}
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule:
@@ -87,10 +88,10 @@
     defaults: plugin-template-bazel
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/{name}
+                credentials-id: gerrit.googlesource.com
           branches:
             - '*/{branch}'
           skip-tag: true
@@ -113,10 +114,10 @@
     defaults: plugin-template-bazel
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/modules/{name}
+                credentials-id: gerrit.googlesource.com
           branches:
             - '*/{branch}'
           skip-tag: true
@@ -139,12 +140,13 @@
     defaults: plugin-template-bazel
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/modules/{name}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - '*/{branch}'
           skip-tag: true
diff --git a/jenkins/gerrit-mvn-plugin-template.yaml b/jenkins/gerrit-mvn-plugin-template.yaml
index e9abb86..f2cccd7 100644
--- a/jenkins/gerrit-mvn-plugin-template.yaml
+++ b/jenkins/gerrit-mvn-plugin-template.yaml
@@ -23,12 +23,13 @@
             - job-extended-read
     scm:
       - git:
-          credentials-id: gerrit.googlesource.com
           remotes:
             - origin:
                 url: https://gerrit.googlesource.com/a/plugins/{repo}
+                credentials-id: gerrit.googlesource.com
             - gerrit:
                 url: https://gerrit.googlesource.com/a/gerrit
+                credentials-id: gerrit.googlesource.com
           branches:
             - origin/{branch}
           submodule: