diff --git a/ci/lib_gitlab_ci/to_yaml.ml b/ci/lib_gitlab_ci/to_yaml.ml index 1c566f1abc3ab667b04733f263b1eaec0901a926..57a54a9b1757bef2fd88496393ada422240cb323 100644 --- a/ci/lib_gitlab_ci/to_yaml.ml +++ b/ci/lib_gitlab_ci/to_yaml.ml @@ -311,14 +311,19 @@ let enc_job : job -> value = opt "parallel" enc_parallel parallel; ] +let enc_inherit : inherit_ -> value = function + | Variable_bool b -> `O (key "variables" bool b) + | Variable_list v -> `O (key "variables" (list string) v) + let enc_trigger_job : trigger_job -> value = let enc_trigger_include trigger_include = `O [("include", `String trigger_include)] in - fun {name = _; stage; when_; rules; needs; trigger_include} -> + fun {name = _; stage; when_; inherit_; rules; needs; trigger_include} -> obj_flatten [ opt "stage" string stage; + opt "inherit" enc_inherit inherit_; opt "rules" enc_job_rules rules; opt "needs" enc_needs needs; opt "when" enc_when_trigger_job when_; diff --git a/ci/lib_gitlab_ci/types.ml b/ci/lib_gitlab_ci/types.ml index e307349d3d9292d971f81d59ecc401619f198b4e..110462b2063a9aa1815b8045c7cf198647d43700 100644 --- a/ci/lib_gitlab_ci/types.ml +++ b/ci/lib_gitlab_ci/types.ml @@ -194,6 +194,11 @@ type matrix = (string * string list) list list YAML keyword reference for more information. *) type parallel = Vector of int | Matrix of matrix +(** Represents an inherit rule. + + See https://docs.gitlab.com/ee/ci/yaml/index.html#inherit *) +type inherit_ = Variable_list of string list | Variable_bool of bool + type job = { name : string; (** Note that [name] does not translate to a field in a job, but @@ -252,6 +257,7 @@ type job = { - [extends]. - [needs], but not [needs:project]. - [only] and [except]. + - [inherit] - [rules]. - [stage]. - [trigger]. @@ -268,6 +274,7 @@ type trigger_job = { name : string; stage : string option; when_ : when_trigger_job option; + inherit_ : inherit_ option; rules : job_rule list option; needs : need list option; trigger_include : string; diff --git a/ci/lib_gitlab_ci/util.ml b/ci/lib_gitlab_ci/util.ml index c221aa01ff3358760c097fac4de0094dea0d301d..7afd6d25565e846a4695c2cce4f0d2fcfb06017c 100644 --- a/ci/lib_gitlab_ci/util.ml +++ b/ci/lib_gitlab_ci/util.ml @@ -59,8 +59,8 @@ let job ?after_script ?allow_failure ?artifacts ?before_script ?cache ?image parallel; } -let trigger_job ?needs ?rules ?stage ?when_ ~name trigger_include = - {name; needs; rules; stage; when_; trigger_include} +let trigger_job ?needs ?inherit_ ?rules ?stage ?when_ ~name trigger_include = + {name; needs; inherit_; rules; stage; when_; trigger_include} let artifacts ?expire_in ?reports ?when_ ?expose_as ?name paths = (match (reports, paths) with diff --git a/ci/lib_gitlab_ci/util.mli b/ci/lib_gitlab_ci/util.mli index 7c68746a5dffb2a9eb077a82e077a065d7d148fe..40b33d56adc999b09440aa9dc8be39803f78a1f8 100644 --- a/ci/lib_gitlab_ci/util.mli +++ b/ci/lib_gitlab_ci/util.mli @@ -86,6 +86,7 @@ val job : (** [trigger_job child_pipeline_path] constructs a {!trigger_job} job. *) val trigger_job : ?needs:need list -> + ?inherit_:inherit_ -> ?rules:job_rule list -> ?stage:string -> ?when_:when_trigger_job ->