Skip to content

Commit 09fd7da

Browse files
authored
Add IgnoreIfAlreadyExists option to Create Release V6 (#341)
* Add IgnoreIfAlreadyExists option to Create Release V6 * Update release ready message
1 parent 0285590 commit 09fd7da

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

source/tasks/CreateOctopusRelease/CreateOctopusReleaseV6/createRelease.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ export async function createReleaseFromInputs(client: Client, command: CreateRel
1010
const repository = new ReleaseRepository(client, command.spaceName);
1111
const response = await repository.create(command);
1212

13-
client.info(`🎉 Release ${response.ReleaseVersion} created successfully!`);
13+
if (command.IgnoreIfAlreadyExists) {
14+
client.info(`🎉 Release ${response.ReleaseVersion} is ready for deployment!`);
15+
} else {
16+
client.info(`🎉 Release ${response.ReleaseVersion} created successfully!`);
17+
}
1418

1519
task.setOutputVariable("release_number", response.ReleaseVersion);
1620

source/tasks/CreateOctopusRelease/CreateOctopusReleaseV6/inputCommandBuilder.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe("getInputCommand", () => {
2121
task.addVariableString("DefaultPackageVersion", "1.0.1");
2222
task.addVariableString("Packages", "Step1:Foo:1.0.0\nBar:2.0.0");
2323
task.addVariableString("GitRef", "main");
24+
task.addVariableBoolean("IgnoreIfAlreadyExists", true);
2425

2526
const command = createCommandFromInputs(logger, task);
2627
expect(command.spaceName).toBe("Default");
@@ -30,6 +31,7 @@ describe("getInputCommand", () => {
3031
expect(command.PackageVersion).toBe("1.0.1");
3132
expect(command.Packages).toStrictEqual(["Step1:Foo:1.0.0", "Bar:2.0.0"]);
3233
expect(command.GitRef).toBe("main");
34+
expect(command.IgnoreIfAlreadyExists).toBe(true);
3335

3436
expect(task.lastResult).toBeUndefined();
3537
expect(task.lastResultMessage).toBeUndefined();

source/tasks/CreateOctopusRelease/CreateOctopusReleaseV6/inputCommandBuilder.ts

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export function createCommandFromInputs(logger: Logger, task: TaskWrapper): Crea
6464
ReleaseNotes: task.getInput("ReleaseNotes"),
6565
GitRef: task.getInput("GitRef"),
6666
GitCommit: task.getInput("GitCommit"),
67+
IgnoreIfAlreadyExists: task.getBoolean("IgnoreIfAlreadyExists") || undefined,
6768
};
6869

6970
const releaseNotesFilePath = task.getInput("ReleaseNotesFile");

source/tasks/CreateOctopusRelease/CreateOctopusReleaseV6/task.json

+9
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@
120120
"helpMarkDown": "Git commit to use when creating the release for version controlled Projects. Use in conjunction with the gitRef parameter to select any previous commit.",
121121
"groupName": "versionControl"
122122
},
123+
{
124+
"name": "IgnoreIfAlreadyExists",
125+
"type": "boolean",
126+
"label": "Ignore Existing Release",
127+
"defaultValue": "",
128+
"required": false,
129+
"helpMarkDown": "If enabled will not attempt to create a new release if there is already one with the same version number",
130+
"groupName": "additional"
131+
},
123132
{
124133
"name": "AdditionalArguments",
125134
"type": "string",

0 commit comments

Comments
 (0)