-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Liftric/feature/promote-release
feat(PromoteRelease): add support for promote release
- Loading branch information
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/kotlin/com/liftric/octopusdeploy/task/PromoteReleaseTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.liftric.octopusdeploy.task | ||
|
||
import com.liftric.octopusdeploy.shell | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
open class PromoteReleaseTask : DefaultTask() { | ||
init { | ||
group = "octopus" | ||
description = "Promotes a release." | ||
outputs.upToDateWhen { false } | ||
} | ||
|
||
@Input | ||
val octopusUrl = project.objects.property(String::class.java) | ||
|
||
@Input | ||
val apiKey = project.objects.property(String::class.java) | ||
|
||
/** | ||
* Target octopus project name | ||
*/ | ||
@Input | ||
val projectName = project.objects.property(String::class.java) | ||
|
||
/** | ||
* Source octopus environment name | ||
*/ | ||
@Input | ||
val from = project.objects.property(String::class.java) | ||
|
||
/** | ||
* Target octopus environment name | ||
*/ | ||
@Input | ||
val to = project.objects.property(String::class.java) | ||
|
||
@TaskAction | ||
fun execute() { | ||
val (exitCode, inputText, errorText) = listOf( | ||
"octo", | ||
"promote-release", | ||
"--server=${octopusUrl.get()}", | ||
"--apiKey=${apiKey.get()}", | ||
"--project=${projectName.get()}", | ||
"--from=${from.get()}", | ||
"--to=${to.get()}" | ||
).joinToString(" ").let { shell(it) } | ||
if (exitCode == 0) { | ||
println(inputText) | ||
println(errorText) | ||
} else { | ||
logger.error("octo promote-release returned non-zero exitCode: $exitCode") | ||
logger.error(inputText) | ||
logger.error(errorText) | ||
throw IllegalStateException("octo promote-release exitCode: $exitCode") | ||
} | ||
} | ||
} |