diff --git a/executor/executor.go b/executor/executor.go index 4dc537b3..b3ff1108 100644 --- a/executor/executor.go +++ b/executor/executor.go @@ -5,6 +5,6 @@ import ( ) // Run will be used to execute steps -func Run(jobDef []screwdriver.JobDef) error { +func Run(jobDefs []screwdriver.JobDef) error { return nil } diff --git a/launch.go b/launch.go index 0b5d8058..e26dde32 100644 --- a/launch.go +++ b/launch.go @@ -103,7 +103,7 @@ func prNumber(jobName string) string { if matched == nil || len(matched) != 2 { return "" } - + log.Println("Build is a PR: ", matched[1]) return matched[1] } diff --git a/launch_test.go b/launch_test.go index dd2b7fcd..72b381b9 100644 --- a/launch_test.go +++ b/launch_test.go @@ -419,10 +419,14 @@ func TestPipelineDefFromYaml(t *testing.T) { testBuildID := "BUILDID" testJobID := "JOBID" testRoot := "/sd/workspace" + mainJob := screwdriver.JobDef{ Image: "node:4", - Steps: map[string]string{ - "install": "npm install", + Commands: []screwdriver.CommandDef{ + screwdriver.CommandDef{ + Name: "install", + Cmd: "npm install", + }, }, Environment: map[string]string{ "NUMBER": "3", diff --git a/screwdriver/screwdriver.go b/screwdriver/screwdriver.go index bb902169..7a9e0bd7 100644 --- a/screwdriver/screwdriver.go +++ b/screwdriver/screwdriver.go @@ -46,7 +46,7 @@ func New(url, token string) (API, error) { return API(api), nil } -// BuildStatus is a Screwdriver Build Status payload +// BuildStatus is a Screwdriver Build Status payload. type BuildStatus struct { Status string `json:"status"` } @@ -56,32 +56,38 @@ type Validator struct { Yaml string `json:"yaml"` } -// Pipeline is a Screwdriver Pipeline definition +// Pipeline is a Screwdriver Pipeline definition. type Pipeline struct { ID string `json:"id"` ScmURL string `json:"scmUrl"` } -// PipelineDef contains the step definitions and jobs for a Pipeline +// PipelineDef contains the step definitions and jobs for a Pipeline. type PipelineDef struct { Jobs map[string][]JobDef `json:"jobs"` Workflow []string `json:"workflow"` } -// JobDef contains the step and environment definitions of a single Job +// JobDef contains the step and environment definitions of a single Job. type JobDef struct { Image string `json:"image"` - Steps map[string]string `json:"steps"` + Commands []CommandDef `json:"commands"` Environment map[string]string `json:"environment"` } -// Job is a Screwdriver Job +// Job is a Screwdriver Job. type Job struct { ID string `json:"id"` PipelineID string `json:"pipelineId"` Name string `json:"name"` } +// CommandDef is the definition of a single executable command. +type CommandDef struct { + Name string `json:"name"` + Cmd string `json:"command"` +} + // Build is a Screwdriver Build type Build struct { ID string `json:"id"` diff --git a/screwdriver/screwdriver_test.go b/screwdriver/screwdriver_test.go index a54a3439..cc25c93f 100644 --- a/screwdriver/screwdriver_test.go +++ b/screwdriver/screwdriver_test.go @@ -182,31 +182,37 @@ func TestPipeline404(t *testing.T) { func TestPipelineFromYaml(t *testing.T) { json := `{ - "jobs": { - "main": [ - { - "image": "node:4", - "steps": { - "install": "npm install" - }, - "environment": { - "ARRAY": "[\"a\",\"b\"]", - "BOOL": "true", - "OBJECT": "{\"a\":\"cat\",\"b\":\"dog\"}", - "NUMBER": "3", - "DECIMAL": "3.1415927", - "STRING": "test" - } - } - ] - }, - "workflow": [] - }` + "jobs": { + "main": [ + { + "image": "node:4", + "commands": [ + { + "name": "install", + "command": "npm install" + } + ], + "environment": { + "ARRAY": "[\"a\",\"b\"]", + "BOOL": "true", + "OBJECT": "{\"a\":\"cat\",\"b\":\"dog\"}", + "NUMBER": "3", + "DECIMAL": "3.1415927", + "STRING": "test" + } + } + ] + }, + "workflow": [] + }` mainJob := JobDef{ Image: "node:4", - Steps: map[string]string{ - "install": "npm install", + Commands: []CommandDef{ + CommandDef{ + Name: "install", + Cmd: "npm install", + }, }, Environment: map[string]string{ "ARRAY": `["a","b"]`,