.gitlab-ci.yml: merge .gitlab-ci-private.yml
authorJoe Guo <joeg@catalyst.net.nz>
Fri, 15 Feb 2019 09:25:07 +0000 (22:25 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 18 Feb 2019 09:54:19 +0000 (10:54 +0100)
`.gitlab-ci.yml` support conditional jobs with `only` and `except`.
And variables can be read from repo CI/CD settings as condition:

    build_samba:
      script: ...
      only:
        variables:
          - $SUPPORT_PRIVATE_TEST == 'yes'

Instead of having 2 copies of yml file, we can use this feature to
trigger private jobs only when a var like `SUPPORT_PRIVATE_TEST` is defined.

I've already added above var to our repos.
Once merged, we can remove custom CI config file in
gitlab repo settings, and remove .gitlab-ci-private.yml file from code.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Mon Feb 18 10:54:19 CET 2019 on sn-devel-144

.gitlab-ci-private.yml
.gitlab-ci.yml

index 4e83c197b8929dd853a6dddf5fd37a48eec237fb..04d33d5c549deaa5b1dccc5eb0103b22f2fa21c6 100644 (file)
@@ -1,30 +1,2 @@
 include:
- - '/.gitlab-ci.yml'
-
-
-.private_template:
-  extends: .shared_template
-  tags:
-    - docker
-    - private
-  before_script:
-    - uname -a
-    - lsb_release -a
-    - mount
-    - df -h
-    - free -h
-
-samba:
-  extends: .private_template
-  # this one takes about 4 hours to finish
-
-samba-fileserver:
-  extends: .private_template
-  # this one takes about 1 hours to finish
-
-samba-ad-dc:
-  extends: .private_template
-  # this one takes about 1 hours to finish
-
-samba-nt4:
-  extends: .private_template
+  - '/.gitlab-ci.yml'
index d999cf4693fa424f6c9d94a10f0fe16246fb1d1f..32a10181bfa5898940f086eef35a2e6cde5e2c03 100644 (file)
@@ -99,3 +99,37 @@ samba-ad-dc-ntvfs:
   extends: .shared_template
   # this one takes about 100 mins to finish
 
+
+.private_template:
+  extends: .shared_template
+  tags:
+    - docker
+    - private
+  before_script:
+    - uname -a
+    - lsb_release -a
+    - mount
+    - df -h
+    - free -h
+  only:
+    variables:
+      # These jobs are only run if the gitlab repo has private runners available.
+      # To enable private jobs, you must add the following var and value to
+      # your gitlab repo by navigating to:
+      # settings -> CI/CD -> Environment variables
+      - $SUPPORT_PRIVATE_TEST == "yes"
+
+samba:
+  extends: .private_template
+  # this one takes about 4 hours to finish
+
+samba-fileserver:
+  extends: .private_template
+  # this one takes about 1 hours to finish
+
+samba-ad-dc:
+  extends: .private_template
+  # this one takes about 1 hours to finish
+
+samba-nt4:
+  extends: .private_template