-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backend: Add simple CI based on groovy dsl
- Loading branch information
Showing
11 changed files
with
338 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.mwguy.vgit.ci.dsl | ||
|
||
class CI { | ||
public Pipeline pipeline | ||
|
||
void pipeline(@DelegatesTo(value = Pipeline) Closure closure) { | ||
closure.resolveStrategy = Closure.DELEGATE_ONLY | ||
closure.delegate = pipeline = new Pipeline() | ||
closure.call() | ||
} | ||
} |
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,9 @@ | ||
package com.mwguy.vgit.ci.dsl | ||
|
||
class Job { | ||
public List<String> commands = [] | ||
|
||
void sh(String command) { | ||
commands << command | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/src/main/groovy/com/mwguy/vgit/ci/dsl/Pipeline.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 com.mwguy.vgit.ci.dsl | ||
|
||
import groovy.transform.NamedParam | ||
|
||
class Pipeline { | ||
public Map<String, String> environment = [:] | ||
public Map<String, Stage> stages = [:] | ||
|
||
void environment(@DelegatesTo(Map) Closure closure) { | ||
environment.with(closure) | ||
} | ||
|
||
void stage(@NamedParam("name") String name, @DelegatesTo(Stage) Closure closure) { | ||
def stage = new Stage(); | ||
closure.resolveStrategy = Closure.DELEGATE_FIRST | ||
closure.delegate = stage | ||
closure.call() | ||
|
||
stages.put(name, stage) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/src/main/groovy/com/mwguy/vgit/ci/dsl/Stage.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,17 @@ | ||
package com.mwguy.vgit.ci.dsl | ||
|
||
import groovy.transform.NamedParam | ||
|
||
class Stage { | ||
public Map<String, Job> jobs = [:] | ||
|
||
void job(@NamedParam("name") String name, @DelegatesTo(Job) Closure closure) { | ||
def job = new Job(); | ||
|
||
closure.delegate = job | ||
closure.resolveStrategy = Closure.DELEGATE_FIRST | ||
closure.call() | ||
|
||
jobs.put(name, job) | ||
} | ||
} |
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
Oops, something went wrong.