-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
633 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
40 changes: 40 additions & 0 deletions
40
job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/PublishOverSshContext.groovy
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,40 @@ | ||
package javaposse.jobdsl.dsl.helpers.step | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
import javaposse.jobdsl.dsl.ContextHelper | ||
import javaposse.jobdsl.dsl.DslContext | ||
|
||
import static com.google.common.base.Preconditions.checkArgument | ||
|
||
class PublishOverSshContext implements Context { | ||
final List<PublishOverSshServerContext> servers = [] | ||
boolean continueOnError | ||
boolean failOnError | ||
boolean alwaysPublishFromMaster | ||
String parameterName | ||
|
||
void continueOnError(boolean continueOnError = true) { | ||
this.continueOnError = continueOnError | ||
} | ||
|
||
void failOnError(boolean failOnError = true) { | ||
this.failOnError = failOnError | ||
} | ||
|
||
void alwaysPublishFromMaster(boolean alwaysPublishFromMaster = true) { | ||
this.alwaysPublishFromMaster = alwaysPublishFromMaster | ||
} | ||
|
||
void parameterizedPublishing(String parameterName) { | ||
this.parameterName = parameterName | ||
} | ||
|
||
void server(String name, @DslContext(PublishOverSshServerContext) Closure serverClosure) { | ||
PublishOverSshServerContext serverContext = new PublishOverSshServerContext(name) | ||
ContextHelper.executeInContext(serverClosure, serverContext) | ||
|
||
checkArgument(!serverContext.transferSets.empty, "At least 1 transferSet must be configured for ${name}") | ||
|
||
servers << serverContext | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...src/main/groovy/javaposse/jobdsl/dsl/helpers/step/PublishOverSshCredentialsContext.groovy
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,21 @@ | ||
package javaposse.jobdsl.dsl.helpers.step | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
|
||
class PublishOverSshCredentialsContext implements Context { | ||
final String username | ||
String pathToKey | ||
String key | ||
|
||
PublishOverSshCredentialsContext(String username) { | ||
this.username = username | ||
} | ||
|
||
void pathToKey(String pathToKey) { | ||
this.pathToKey = pathToKey | ||
} | ||
|
||
void key(String key) { | ||
this.key = key | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...core/src/main/groovy/javaposse/jobdsl/dsl/helpers/step/PublishOverSshServerContext.groovy
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,56 @@ | ||
package javaposse.jobdsl.dsl.helpers.step | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
import javaposse.jobdsl.dsl.ContextHelper | ||
import javaposse.jobdsl.dsl.DslContext | ||
|
||
import static com.google.common.base.Preconditions.checkArgument | ||
import static com.google.common.base.Strings.isNullOrEmpty | ||
|
||
class PublishOverSshServerContext implements Context { | ||
final String name | ||
final List<PublishOverSshTransferSetContext> transferSets = [] | ||
boolean verbose | ||
String label | ||
boolean retry | ||
long retries | ||
long delay | ||
PublishOverSshCredentialsContext credentials | ||
|
||
PublishOverSshServerContext(String name) { | ||
this.name = name | ||
} | ||
|
||
void verbose(boolean verbose = true) { | ||
this.verbose = verbose | ||
} | ||
|
||
void label(String label) { | ||
this.label = label | ||
} | ||
|
||
void retry(int retries = 0, int delay = 10000) { | ||
this.retry = true | ||
this.retries = retries | ||
this.delay = delay | ||
} | ||
|
||
void credentials(String username, @DslContext(PublishOverSshCredentialsContext) Closure credentialsClosure) { | ||
PublishOverSshCredentialsContext credentialsContext = new PublishOverSshCredentialsContext(username) | ||
ContextHelper.executeInContext(credentialsClosure, credentialsContext) | ||
|
||
credentials = credentialsContext | ||
} | ||
|
||
void transferSet(@DslContext(PublishOverSshTransferSetContext) Closure transferSetClosure) { | ||
PublishOverSshTransferSetContext transferSetContext = new PublishOverSshTransferSetContext() | ||
ContextHelper.executeInContext(transferSetClosure, transferSetContext) | ||
|
||
checkArgument( | ||
!isNullOrEmpty(transferSetContext.sourceFiles) || !isNullOrEmpty(transferSetContext.execCommand), | ||
'sourceFiles or execCommand must be specified' | ||
) | ||
|
||
transferSets << transferSetContext | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...src/main/groovy/javaposse/jobdsl/dsl/helpers/step/PublishOverSshTransferSetContext.groovy
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,66 @@ | ||
package javaposse.jobdsl.dsl.helpers.step | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
|
||
class PublishOverSshTransferSetContext implements Context { | ||
String sourceFiles | ||
String execCommand | ||
String removePrefix | ||
String remoteDirectory | ||
String excludeFiles | ||
String patternSeparator = '[, ]+' | ||
boolean noDefaultExcludes | ||
boolean makeEmptyDirs | ||
boolean flattenFiles | ||
boolean remoteDirIsDateFormat | ||
long execTimeout = 120000 | ||
boolean execInPty | ||
|
||
void sourceFiles(String sourceFiles) { | ||
this.sourceFiles = sourceFiles | ||
} | ||
|
||
void execCommand(String execCommand) { | ||
this.execCommand = execCommand | ||
} | ||
|
||
void removePrefix(String prefix) { | ||
this.removePrefix = prefix | ||
} | ||
|
||
void remoteDirectory(String remoteDirectory) { | ||
this.remoteDirectory = remoteDirectory | ||
} | ||
|
||
void excludeFiles(String excludeFiles) { | ||
this.excludeFiles = excludeFiles | ||
} | ||
|
||
void patternSeparator(String patternSeparator) { | ||
this.patternSeparator = patternSeparator | ||
} | ||
|
||
void noDefaultExcludes(boolean noDefaultExcludes = true) { | ||
this.noDefaultExcludes = noDefaultExcludes | ||
} | ||
|
||
void makeEmptyDirs(boolean makeEmptyDirs = true) { | ||
this.makeEmptyDirs = makeEmptyDirs | ||
} | ||
|
||
void flattenFiles(boolean flattenFiles = true) { | ||
this.flattenFiles = flattenFiles | ||
} | ||
|
||
void remoteDirIsDateFormat(boolean remoteDirIsDateFormat = true) { | ||
this.remoteDirIsDateFormat = remoteDirIsDateFormat | ||
} | ||
|
||
void execTimeout(long execTimeout) { | ||
this.execTimeout = execTimeout | ||
} | ||
|
||
void execInPty(boolean execInPty = true) { | ||
this.execInPty = execInPty | ||
} | ||
} |
Oops, something went wrong.