Initial commit: Spicy CDK automation framework
Jenkins shared library and CDK constructs for AWS infrastructure. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
45
vars/spicyUtils.groovy
Normal file
45
vars/spicyUtils.groovy
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Utility functions for Spicy CDK pipelines
|
||||
*/
|
||||
|
||||
def setPipelineProperties(baseProperties, propertiesToRemove) {
|
||||
def props = []
|
||||
if (baseProperties) {
|
||||
props.addAll(baseProperties)
|
||||
}
|
||||
if (propertiesToRemove) {
|
||||
props.removeAll(propertiesToRemove)
|
||||
}
|
||||
echo("Setting pipeline properties to ${props}")
|
||||
properties(props)
|
||||
}
|
||||
|
||||
def stageWithFailure(stageName, Map args = [:], Closure body) {
|
||||
customStage([
|
||||
stageName: stageName,
|
||||
failOnError: true
|
||||
] + args, body)
|
||||
}
|
||||
|
||||
def stageWithWarning(stageName, Map args = [:], Closure body) {
|
||||
customStage([
|
||||
stageName: stageName,
|
||||
failOnError: false
|
||||
] + args, body)
|
||||
}
|
||||
|
||||
def customStage(Map args, Closure body) {
|
||||
stage(args.stageName) {
|
||||
try {
|
||||
body()
|
||||
} catch (err) {
|
||||
if (args.failOnError) {
|
||||
throw err
|
||||
}
|
||||
println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
||||
|
||||
Reference in New Issue
Block a user