diff --git a/README.md b/README.md index afba3c3..dbc9211 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ conform. [metadata](http://concourse.ci/implementing-resources.html#resource-metadata) in the status will be evaluated prior to sending the tweet. Use `media` to include references to photos or video +* or `statusFile`: A file (generated by your task) that contains the text to tweet. ##### Optional: * `media`: An array of paths to images or video to upload. Any media referenced diff --git a/ci/tasks/build-resource.yml b/ci/tasks/build-resource.yml index dcf9269..0d96015 100644 --- a/ci/tasks/build-resource.yml +++ b/ci/tasks/build-resource.yml @@ -1,7 +1,11 @@ --- platform: linux -image: docker:///golang#1.6-alpine +image_resource: + type: docker-image + source: + repository: golang + tag: 1.6-alpine inputs: - name: source-code diff --git a/cmd/out/main.go b/cmd/out/main.go index fc5daff..7c3f24a 100644 --- a/cmd/out/main.go +++ b/cmd/out/main.go @@ -53,8 +53,19 @@ func main() { concourse.Sayf("Upload of %v complete\n", imageFile) } + statusText := request.Params.Status + if request.Params.StatusFile != "" { + statusFileContent, fileErr := ioutil.ReadFile(path.Join(workingDir, request.Params.StatusFile)) + if fileErr != nil { + concourse.Fatal("Error reading file: %v\n", fileErr) + } else { + statusText = string(statusFileContent) + } + + } + // expand any variables - statusText := os.ExpandEnv(request.Params.Status) + statusText = os.ExpandEnv(statusText) concourse.Sayf("Posting tweet '%s'\n", statusText) output := concourse.OutResponse{} diff --git a/concourse/models.go b/concourse/models.go index 3cd008d..46054f9 100644 --- a/concourse/models.go +++ b/concourse/models.go @@ -18,6 +18,7 @@ type MetadataPair struct { type OutParams struct { Status string `json:"status"` + StatusFile string `json:"statusFile"` Media []string `json:"media,omitempty"` }