Skip to content

Commit 493f3a1

Browse files
authored
Expose ci_delete_pipelines_in_seconds via Project API (#1269)
1 parent 310217a commit 493f3a1

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

gitlab4j-api/src/main/java/org/gitlab4j/api/ProjectApi.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ public Project createProject(Project project) throws GitLabApiException {
10741074
* ciConfigPath (optional) - Set path to CI configuration file
10751075
* autoDevopsEnabled (optional) - Enable Auto DevOps for this project
10761076
* squashOption (optional) - set squash option for merge requests
1077+
* ciDeletePipelinesInSeconds (optional) - set the automatic pipeline cleanup time in seconds
10771078
*
10781079
* @param project the Project instance with the configuration for the new project
10791080
* @param importUrl the URL to import the repository from
@@ -1125,6 +1126,7 @@ public Project createProject(Project project, String importUrl) throws GitLabApi
11251126
.withParam("build_git_strategy", project.getBuildGitStrategy())
11261127
.withParam("build_coverage_regex", project.getBuildCoverageRegex())
11271128
.withParam("ci_config_path", project.getCiConfigPath())
1129+
.withParam("ci_delete_pipelines_in_seconds", project.getCiDeletePipelinesInSeconds())
11281130
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
11291131
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())
11301132
.withParam("auto_devops_enabled", project.getAutoDevopsEnabled())
@@ -1445,6 +1447,7 @@ public Project createProjectFromTemplate(
14451447
* ciConfigPath (optional) - Set path to CI configuration file
14461448
* ciForwardDeploymentEnabled (optional) - When a new deployment job starts, skip older deployment jobs that are still pending
14471449
* squashOption (optional) - set squash option for merge requests
1450+
* ciDeletePipelinesInSeconds (optional) - set the automatic pipeline cleanup time in seconds
14481451
*
14491452
* NOTE: The following parameters specified by the GitLab API edit project are not supported:
14501453
* import_url
@@ -1494,6 +1497,7 @@ public Project updateProject(Project project) throws GitLabApiException {
14941497
.withParam("build_coverage_regex", project.getBuildCoverageRegex())
14951498
.withParam("ci_config_path", project.getCiConfigPath())
14961499
.withParam("ci_forward_deployment_enabled", project.getCiForwardDeploymentEnabled())
1500+
.withParam("ci_delete_pipelines_in_seconds", project.getCiDeletePipelinesInSeconds())
14971501
.withParam("merge_method", project.getMergeMethod())
14981502
.withParam("suggestion_commit_message", project.getSuggestionCommitMessage())
14991503
.withParam("remove_source_branch_after_merge", project.getRemoveSourceBranchAfterMerge())

gitlab4j-api/src/test/java/org/gitlab4j/api/TestProjectApi.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ public void testUpdate() throws GitLabApiException {
274274
.withTagList(Arrays.asList("tag1", "tag2"))
275275
.withMergeMethod(Project.MergeMethod.MERGE)
276276
.withSuggestionCommitMessage("SuggestionCommitMessageOriginal")
277-
.withRemoveSourceBranchAfterMerge(false);
277+
.withRemoveSourceBranchAfterMerge(false)
278+
.withCiDeletePipelineInSeconds(3600);
278279

279280
Project newProject = gitLabApi.getProjectApi().createProject(project);
280281
assertNotNull(newProject);
@@ -289,6 +290,7 @@ public void testUpdate() throws GitLabApiException {
289290
assertEquals(Project.MergeMethod.MERGE, newProject.getMergeMethod());
290291
assertEquals(project.getSuggestionCommitMessage(), newProject.getSuggestionCommitMessage());
291292
assertEquals(project.getRemoveSourceBranchAfterMerge(), newProject.getRemoveSourceBranchAfterMerge());
293+
assertEquals(project.getCiDeletePipelinesInSeconds(), newProject.getCiDeletePipelinesInSeconds());
292294

293295
project = new Project()
294296
.withId(newProject.getId())

gitlab4j-models/src/main/java/org/gitlab4j/api/models/Project.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public String toString() {
155155
private String ciRestrictPipelineCancellationRole;
156156
private String ciPipelineVariablesMinimumOverrideRole;
157157
private Boolean ciPushRepositoryForJobTokenAllowed;
158+
private Integer ciDeletePipelinesInSeconds;
158159
private Boolean allowPipelineTriggerApproveDeployment;
159160
private Boolean restrictUserDefinedVariables;
160161
private Boolean enforceAuthChecksOnUploads;
@@ -1383,6 +1384,19 @@ public void setCiPushRepositoryForJobTokenAllowed(Boolean ciPushRepositoryForJob
13831384
this.ciPushRepositoryForJobTokenAllowed = ciPushRepositoryForJobTokenAllowed;
13841385
}
13851386

1387+
public Integer getCiDeletePipelinesInSeconds() {
1388+
return ciDeletePipelinesInSeconds;
1389+
}
1390+
1391+
public void setCiDeletePipelinesInSeconds(Integer ciDeletePipelinesInSeconds) {
1392+
this.ciDeletePipelinesInSeconds = ciDeletePipelinesInSeconds;
1393+
}
1394+
1395+
public Project withCiDeletePipelineInSeconds(Integer ciDeletePipelineInSeconds) {
1396+
this.ciDeletePipelinesInSeconds = ciDeletePipelineInSeconds;
1397+
return this;
1398+
}
1399+
13861400
public Boolean getAllowPipelineTriggerApproveDeployment() {
13871401
return allowPipelineTriggerApproveDeployment;
13881402
}

gitlab4j-models/src/test/resources/org/gitlab4j/models/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,6 @@
194194
"requirements_access_level" : "enabled",
195195
"security_and_compliance_access_level" : "private",
196196
"snippets_access_level" : "enabled",
197-
"wiki_access_level" : "enabled"
197+
"wiki_access_level" : "enabled",
198+
"ci_delete_pipelines_in_seconds": 604800
198199
}

0 commit comments

Comments
 (0)