Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'rgal/JENKINS-32391'
- Loading branch information
Showing
6 changed files
with
213 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
12 changes: 12 additions & 0 deletions
12
...dsl-core/src/main/docs/examples/javaposse/jobdsl/dsl/helpers/ScmContext/perforceP4.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,12 @@ | ||
job('example') { | ||
scm { | ||
perforceP4('p4_credentials') { | ||
workspace { | ||
manual('ws_name', '//depot/Tools/build/... //ws_name/build/...') | ||
} | ||
configure { node -> | ||
node / workspace / spec / clobber('true') | ||
} | ||
} | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/P4Context.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,26 @@ | ||
package javaposse.jobdsl.dsl.helpers.scm | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
import javaposse.jobdsl.dsl.ContextHelper | ||
import javaposse.jobdsl.dsl.DslContext | ||
|
||
class P4Context implements Context { | ||
P4WorkspaceContext workspaceContext = new P4WorkspaceContext() | ||
Closure withXmlClosure | ||
|
||
/** | ||
* Sets the appropriate Perforce workspace behaviour. | ||
*/ | ||
void workspace(@DslContext(P4WorkspaceContext) Closure closure) { | ||
ContextHelper.executeInContext(closure, workspaceContext) | ||
} | ||
|
||
/** | ||
* Allows direct manipulation of the generated XML. The {@code scm} node is passed into the configure block. | ||
* | ||
* @see <a href="https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block">The Configure Block</a> | ||
*/ | ||
void configure(Closure withXmlClosure) { | ||
this.withXmlClosure = withXmlClosure | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
job-dsl-core/src/main/groovy/javaposse/jobdsl/dsl/helpers/scm/P4WorkspaceContext.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,33 @@ | ||
package javaposse.jobdsl.dsl.helpers.scm | ||
|
||
import javaposse.jobdsl.dsl.Context | ||
|
||
class P4WorkspaceContext implements Context { | ||
Node workspaceConfig | ||
|
||
P4WorkspaceContext() { | ||
manual('', '') | ||
} | ||
|
||
/** | ||
* Set up a manual workspace with workspace name and view spec. | ||
*/ | ||
void manual(String workspaceName, String viewSpec) { | ||
workspaceConfig = new NodeBuilder().workspace(class: 'org.jenkinsci.plugins.p4.workspace.ManualWorkspaceImpl') { | ||
charset('none') | ||
pinHost(false) | ||
name(workspaceName ?: '') | ||
spec { | ||
allwrite(false) | ||
clobber(false) | ||
compress(false) | ||
locked(false) | ||
modtime(false) | ||
rmdir(false) | ||
streamName() | ||
line('LOCAL') | ||
view(viewSpec ?: '') | ||
} | ||
} | ||
} | ||
} |
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