Reworking runs to include an id, save the run request.

This commit is contained in:
Jonathan Bernard
2017-05-11 10:51:06 -05:00
parent e2c3aeca09
commit 3d8454d486
6 changed files with 75 additions and 20 deletions

View File

@ -1,4 +1,4 @@
import docopt, os, sequtils, tempfile
import docopt, os, sequtils, tempfile, uuids
import strawbosspkg/private/util
import strawbosspkg/configuration
@ -31,6 +31,9 @@ Options
-r --reference <ref> Build the project at this commit reference.
-i --run-id <id> Use the given UUID as the run ID. If not given, a
new UUID is generated for this run.
-w --workspace <workspace> Use the given directory as the build workspace.
"""
@ -51,14 +54,17 @@ Options
if args["run"]:
let req = RunRequest(
projectName: $args["<project>"],
stepName: $args["<step>"],
buildRef: if args["--reference"]: $args["--reference"] else: nil,
forceRebuild: args["--force-rebuild"],
workspaceDir: if args["--workspace"]: $args["<workspace>"] else: mkdtemp())
let wkspDir = if args["--workspace"]: $args["--workspace"] else: mkdtemp()
try:
let req = RunRequest(
id: if args["--run-id"]: parseUUID($args["--run-id"]) else: genUUID(),
projectName: $args["<project>"],
stepName: $args["<step>"],
buildRef: if args["--reference"]: $args["--reference"] else: nil,
forceRebuild: args["--force-rebuild"],
workspaceDir: wkspDir)
let status = core.runStep(cfg, req, logProcOutput)
if status.state == "failed": raiseEx status.details
echo "strawboss: build passed."
@ -66,7 +72,7 @@ Options
echo "strawboss: build FAILED: " & getCurrentExceptionMsg() & "."
quit(QuitFailure)
finally:
if existsDir(req.workspaceDir): removeDir(req.workspaceDir)
if existsDir(wkspDir): removeDir(wkspDir)
elif args["serve"]: server.start(cfg)