diff --git a/src/com/puzzleitc/jenkins/MavenCoordinates.groovy b/src/com/puzzleitc/jenkins/MavenCoordinates.groovy deleted file mode 100644 index e060a5d..0000000 --- a/src/com/puzzleitc/jenkins/MavenCoordinates.groovy +++ /dev/null @@ -1,63 +0,0 @@ -package com.puzzleitc.jenkins - -class MavenCoordinates implements Serializable { - String groupId - String artifactId - String version - String packaging - String classifier - - @com.cloudbees.groovy.cps.NonCPS - String toString() { - return "${groupId}:${artifactId}:${version}:${packaging}${classifier?.trim() ? ":${classifier}" : "" }" - } - - @com.cloudbees.groovy.cps.NonCPS - int hashCode() { - final int prime = 31 - int result = 1 - result = prime * result + ((artifactId == null) ? 0 : artifactId.hashCode()) - result = prime * result + ((classifier == null) ? 0 : classifier.hashCode()) - result = prime * result + ((groupId == null) ? 0 : groupId.hashCode()) - result = prime * result + ((packaging == null) ? 0 : packaging.hashCode()) - result = prime * result + ((version == null) ? 0 : version.hashCode()) - return result - } - - @com.cloudbees.groovy.cps.NonCPS - boolean equals(Object obj) { - if (this == obj) - return true - if (obj == null) - return false - if (getClass() != obj.getClass()) - return false - MavenCoordinates other = (MavenCoordinates) obj - if (artifactId == null) { - if (other.artifactId != null) - return false - } else if (!artifactId.equals(other.artifactId)) - return false - if (classifier == null) { - if (other.classifier != null) - return false - } else if (!classifier.equals(other.classifier)) - return false - if (groupId == null) { - if (other.groupId != null) - return false - } else if (!groupId.equals(other.groupId)) - return false - if (packaging == null) { - if (other.packaging != null) - return false - } else if (!packaging.equals(other.packaging)) - return false - if (version == null) { - if (other.version != null) - return false - } else if (!version.equals(other.version)) - return false - return true - } -} diff --git a/src/com/puzzleitc/jenkins/Util.groovy b/src/com/puzzleitc/jenkins/Util.groovy deleted file mode 100644 index 240a083..0000000 --- a/src/com/puzzleitc/jenkins/Util.groovy +++ /dev/null @@ -1,60 +0,0 @@ -package com.puzzleitc.jenkins - -// This class is deprecated, use src/com/puzzleitc/jenkins/util/Args.groovy instead - -@Deprecated -class Util { - static Map parseArgs(namedArgs, positionalArgs, List requiredParams, Map optionalParams = [:]) { - - // null can be incorrectly assigned to namedArgs or positionalArgs if there are no other named or positional arguments, fix it - if (namedArgs == null) { - namedArgs = [:] - positionalArgs = ([null] as Object[]) + positionalArgs - } - if (positionalArgs == null) { - positionalArgs = ([null] as Object[]) - } - - // If the last argument is a closure it always goes into the last parameter - def positionalArgsCount = positionalArgs?.length - if (positionalArgsCount && positionalArgs[-1] instanceof Closure) { - println("closure") - def lastKey = optionalParams.size() ? optionalParams.keySet().last() : requiredParams[-1] - namedArgs[lastKey] = positionalArgs[-1] - positionalArgsCount-- - } - - int i = 0 - for (def item: requiredParams) { - if (namedArgs.containsKey(item)) { - if (i < positionalArgsCount) { - throw new IllegalArgumentException("Multiple values for argument '${item}'") - } - } else { - if (i < positionalArgsCount) { - namedArgs[item] = positionalArgs[i] - } else { - throw new IllegalArgumentException("Missing argument '${item}'") - } - } - i++ - } - - for (def item: optionalParams) { - if (namedArgs.containsKey(item.key)) { - if (i < positionalArgsCount) { - throw new IllegalArgumentException("Multiple values for argument '${item.key}'") - } - } else { - if (i < positionalArgsCount) { - namedArgs[item.key] = positionalArgs[i] - } else { - namedArgs[item.key] = item.value - } - } - i++ - } - - return namedArgs - } -} diff --git a/src/com/puzzleitc/jenkins/command/AddDeployLinksCommand.groovy b/src/com/puzzleitc/jenkins/command/AddDeployLinksCommand.groovy deleted file mode 100644 index c0623f8..0000000 --- a/src/com/puzzleitc/jenkins/command/AddDeployLinksCommand.groovy +++ /dev/null @@ -1,27 +0,0 @@ -package com.puzzleitc.jenkins.command - -import com.puzzleitc.jenkins.command.context.PipelineContext -import com.puzzleitc.jenkins.command.context.StepParams - -class AddDeployLinksCommand { - - private final PipelineContext ctx - - AddDeployLinksCommand(PipelineContext ctx) { - this.ctx = ctx - } - - void execute() { - ctx.info('-- AddDeployLinks --') - def deployJob = ctx.stepParams.getOptional('deployJob') - if (deployJob == null) { - error(ctx.getClass().getName() + ': No deploymentJob found. Must be specified!') - } - ctx.echo("deployJob: " + deployJob) - def deploymentJob = Jenkins.instance.getItemByFullName(deployJob) - if (deploymentJob == null) { - error(ctx.getClass().getName() + ": can't find job '${deploymentJob}'!" ) - } - ctx.addHtmlBadge html:"Deploy " - } -} \ No newline at end of file diff --git a/src/com/puzzleitc/jenkins/command/GitCryptCommand.groovy b/src/com/puzzleitc/jenkins/command/GitCryptCommand.groovy deleted file mode 100644 index c28068c..0000000 --- a/src/com/puzzleitc/jenkins/command/GitCryptCommand.groovy +++ /dev/null @@ -1,34 +0,0 @@ -package com.puzzleitc.jenkins.command - -import com.puzzleitc.jenkins.command.context.PipelineContext - -class GitCryptCommand { - - private final PipelineContext ctx - - GitCryptCommand(PipelineContext ctx) { - this.ctx = ctx - } - - void execute() { - def credentialsId = ctx.stepParams.getRequired('credentialsId') as String - def body = ctx.stepParams.getRequired('body') as Closure - def gitCryptPath = ctx.executable('git-crypt', 'gitcrypt') - def unlocked = false - try { - if (credentialsId) { - ctx.info('-- git-crypt unlock --') - ctx.withCredentials([ctx.file(credentialsId: credentialsId, variable: 'GIT_CRYPT_KEYFILE')]) { - ctx.sh script: "${gitCryptPath}/git-crypt unlock \${GIT_CRYPT_KEYFILE}" - unlocked = true - } - } - body() - } finally { - if (unlocked) { - ctx.info('-- git-crypt lock --') - ctx.sh script: "${gitCryptPath}/git-crypt lock" - } - } - } -} diff --git a/src/com/puzzleitc/jenkins/command/ReplaceFromVaultCommand.groovy b/src/com/puzzleitc/jenkins/command/ReplaceFromVaultCommand.groovy deleted file mode 100644 index 9bf4905..0000000 --- a/src/com/puzzleitc/jenkins/command/ReplaceFromVaultCommand.groovy +++ /dev/null @@ -1,43 +0,0 @@ -package com.puzzleitc.jenkins.command - -import com.puzzleitc.jenkins.command.context.PipelineContext - -class ReplaceFromVaultCommand { - - private final PipelineContext ctx - - ReplaceFromVaultCommand(PipelineContext ctx) { - this.ctx = ctx - } - - Object execute() { - ctx.info('-- replaceFromVault --') - def text = ctx.stepParams.getRequired('text') as String - def result = text - while (parseVaultLookup(result).size() > 0) { - def match = parseVaultLookup(result).get(0) - if (match.path) { - def replacedValue = ctx.lookupValueFromVault(match.path, match.key) - result = result.substring(0, match.start) + replacedValue + result.substring(match.end, result.length()) - } - } - return result - } - - private static List parseVaultLookup(String lookup) { - def matcher = lookup =~ /(?m)\{\{\s*vault\.get\(\s*"([^"]+)",\s*"([^"]+)"\s*\)\s*\}\}/ - def result = [] - while (matcher.find()) { - result.add(new VaultMatch(path: matcher.group(1), key: matcher.group(2), start: matcher.start(), end: matcher.end())) - } - return result - } - - private static class VaultMatch { - String path - String key - int start - int end - } - -}