[concourse] Add support for build_log_retention attribute
See: https://github.com/spring-projects/sts4/issues/389
This commit is contained in:
@@ -405,12 +405,18 @@ public class PipelineYmlSchema implements YamlSchema {
|
||||
}
|
||||
models.setStepType(step);
|
||||
|
||||
YBeanType t_retention_config = f.ybean("RetentionConfig");
|
||||
addProp(t_retention_config, "days", t_pos_integer);
|
||||
addProp(t_retention_config, "builds", t_pos_integer);
|
||||
addProp(t_retention_config, "minimum_succeeded_builds", t_pos_integer);
|
||||
|
||||
AbstractType job = f.ybean("Job");
|
||||
addProp(job, "name", jobNameDef).isPrimary(true);
|
||||
addProp(job, "old_name", t_ne_string);
|
||||
addProp(job, "plan", f.yseq(step)).isRequired(true);
|
||||
addProp(job, "serial", t_boolean);
|
||||
addProp(job, "build_logs_to_retain", t_pos_integer);
|
||||
addProp(job, "build_logs_to_retain", t_pos_integer).isDeprecated("Deprecated in favor of `build_log_retention`");
|
||||
addProp(job, "build_log_retention", t_retention_config);
|
||||
addProp(job, "serial_groups", t_strings);
|
||||
addProp(job, "max_in_flight", t_pos_integer);
|
||||
addProp(job, "public", t_boolean);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
*Optional*. Configures the retention policy for build logs. This is useful if you have a job that runs often but after
|
||||
some amount of time the logs aren't worth keeping around.
|
||||
|
||||
The following fields may be specified: `days`, `builds`, `minimum_succeeded_builds`.
|
||||
|
||||
Builds which are not retained by one of the above configurations will have their logs reaped.
|
||||
|
||||
The following example will keep logs for any builds that have completed in the last 2 days, while also keeping the last 1000 builds, with at least one successful build.
|
||||
|
||||
jobs:
|
||||
- name: smoke-tests
|
||||
build_log_retention:
|
||||
days: 2
|
||||
builds: 1000
|
||||
minimum_succeeded_builds: 1
|
||||
plan:
|
||||
- get: 10m
|
||||
- task: smoke-tests
|
||||
# ...
|
||||
|
||||
Note: if more than 1000 builds finish in the past 2 days, all of them will be retained thanks to the build_log_retention.days configuration. Similarly, if there are 1000 builds spanning more than 2 days, they will also be kept thanks to the build_log_retention.builds configuration. And if they all happened to have failed, the build_log_retention.minimum_succeeded_builds will keep around at least one successful build. All policies operate independently.
|
||||
@@ -1,10 +0,0 @@
|
||||
<p><em>Optional.</em> If configured, only the last specified number of builds
|
||||
will have their build logs persisted. This is useful if you have a job that
|
||||
runs periodically but after some amount of time the logs aren't worth keeping
|
||||
around.</p><p>Example:</p><div class="highlight"><pre class="verbatim"><span class="t"></span><span class="t"></span><span class="t"></span><span class="nv"></span><span class="py">jobs</span><span class="t"></span><span class="pi">:</span><span class="t"></span><span class="t"></span><span class="t"></span><span class="t">
|
||||
</span><span class="t"></span><span class="pi">-</span><span class="t"></span><span class="t"> </span><span class="t"></span><span class="nv"></span><span class="py">name</span><span class="t"></span><span class="pi">:</span><span class="t"></span><span class="t"> </span><span class="nv"></span><span class="nv">smoke-tests</span><span class="t">
|
||||
</span><span class="t"> </span><span class="t"></span><span class="t"></span><span class="t"></span><span class="t"></span><span class="nv"></span><span class="py">build_logs_to_retain</span><span class="t"></span><span class="pi">:</span><span class="t"></span><span class="t"> </span><span class="mi">100</span><span class="t"></span><span class="t"></span><span class="t">
|
||||
</span><span class="t"> </span><span class="t"></span><span class="t"></span><span class="nv"></span><span class="py">plan</span><span class="t"></span><span class="pi">:</span><span class="t"></span><span class="t"></span><span class="t"></span><span class="t">
|
||||
</span><span class="t"> </span><span class="pi">-</span><span class="t"></span><span class="t"> </span><span class="t"></span><span class="nv"></span><span class="py">get</span><span class="t"></span><span class="pi">:</span><span class="t"></span><span class="t"> </span><span class="mi">10</span><span class="nv"></span><span class="nv">m</span><span class="t">
|
||||
</span><span class="t"> </span><span class="t"></span><span class="t"></span><span class="pi">-</span><span class="t"></span><span class="t"> </span><span class="t"></span><span class="nv"></span><span class="py">task</span><span class="t"></span><span class="pi">:</span><span class="t"></span><span class="t"> </span><span class="nv"></span><span class="nv">smoke-tests</span><span class="t">
|
||||
</span><span class="t"> </span><span class="nv">#</span><span class="sp"> </span><span class="nv">...</span></pre></div>
|
||||
@@ -0,0 +1,6 @@
|
||||
*Optional*. Deprecated in favor of `build_log_retention`.
|
||||
|
||||
Equivalent to the following:
|
||||
|
||||
build_log_retention:
|
||||
builds: number
|
||||
@@ -0,0 +1 @@
|
||||
*Optional*. Keep logs for the last specified number of builds
|
||||
@@ -0,0 +1 @@
|
||||
*Optional*. Keep logs for builds which have finished within the specified number of days.
|
||||
@@ -0,0 +1 @@
|
||||
*Optional*. Keep logs for at least N successful builds.
|
||||
@@ -4016,6 +4016,10 @@ public class ConcourseEditorTest {
|
||||
" old_name: formerly-known-as\n" +
|
||||
" serial: true\n" +
|
||||
" build_logs_to_retain: 10\n" +
|
||||
" build_log_retention:\n" +
|
||||
" days: 1\n" +
|
||||
" builds: 2\n" +
|
||||
" minimum_succeeded_builds: 1\n" +
|
||||
" serial_groups: []\n" +
|
||||
" max_in_flight: 3\n" +
|
||||
" public: false\n" +
|
||||
@@ -4040,11 +4044,14 @@ public class ConcourseEditorTest {
|
||||
" uri: blah\n" +
|
||||
" branch: master\n"
|
||||
);
|
||||
editor.assertProblems(/*NONE*/);
|
||||
editor.assertHoverContains("name", "The name of the job");
|
||||
editor.assertHoverContains("old_name", "history of old job will be inherited to the new one");
|
||||
editor.assertHoverContains("serial", "execute one-by-one");
|
||||
editor.assertHoverContains("build_logs_to_retain", "only the last specified number of builds");
|
||||
editor.assertHoverContains("build_logs_to_retain", "Deprecated");
|
||||
editor.assertHoverContains("build_log_retention", "Configures the retention policy for build logs");
|
||||
editor.assertHoverContains("days", "Keep logs for builds which have finished within the specified number of days");
|
||||
editor.assertHoverContains("builds", "Keep logs for the last specified number of builds");
|
||||
editor.assertHoverContains("minimum_succeeded_builds", "Keep logs for at least N successful builds");
|
||||
editor.assertHoverContains("serial_groups", "referencing the same tags will be serialized");
|
||||
editor.assertHoverContains("max_in_flight", "maximum number of builds to run at a time");
|
||||
editor.assertHoverContains("public", "build log of this job will be viewable");
|
||||
@@ -4064,6 +4071,10 @@ public class ConcourseEditorTest {
|
||||
" old_name: formerly-known-as\n" +
|
||||
" serial: isSerial\n" +
|
||||
" build_logs_to_retain: retainers\n" +
|
||||
" build_log_retention:\n" +
|
||||
" days: retain-days\n" +
|
||||
" builds: retain-builds\n" +
|
||||
" minimum_succeeded_builds: succ-builds\n" +
|
||||
" serial_groups: no-list\n" +
|
||||
" max_in_flight: flying-number\n" +
|
||||
" public: publicize\n" +
|
||||
@@ -4092,7 +4103,11 @@ public class ConcourseEditorTest {
|
||||
);
|
||||
editor.assertProblems(
|
||||
"isSerial|boolean",
|
||||
"build_logs_to_retain|Deprecated",
|
||||
"retainers|Number",
|
||||
"retain-days|Number",
|
||||
"retain-builds|Number",
|
||||
"succ-builds|Number",
|
||||
"no-list|Expecting a 'Sequence'",
|
||||
"flying-number|Number",
|
||||
"publicize|boolean",
|
||||
@@ -4120,7 +4135,7 @@ public class ConcourseEditorTest {
|
||||
|
||||
editor.assertCompletionLabels(
|
||||
//completions for current (i.e Job) context:
|
||||
"build_logs_to_retain",
|
||||
"build_log_retention",
|
||||
"disable_manual_trigger",
|
||||
"ensure",
|
||||
"interruptible",
|
||||
@@ -4132,6 +4147,7 @@ public class ConcourseEditorTest {
|
||||
"on_success",
|
||||
"serial",
|
||||
"serial_groups",
|
||||
"build_logs_to_retain",
|
||||
//"name", exists
|
||||
//"plan", exists
|
||||
//"public", exists
|
||||
|
||||
Reference in New Issue
Block a user