From 36dc8e02273541ccffef5287965636a2cd3135e0 Mon Sep 17 00:00:00 2001 From: Thomas Detoux Date: Mon, 5 Feb 2018 21:58:06 -0500 Subject: [PATCH 1/2] Add the possibility to tweet the content of a file (possibly generated by a task) --- README.md | 1 + cmd/out/main.go | 13 ++++++++++++- concourse/models.go | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) 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/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"` } From 8d5e0b4a3270da351b94f7070bd42b8d75909f1d Mon Sep 17 00:00:00 2001 From: Thomas Detoux Date: Mon, 5 Feb 2018 22:19:29 -0500 Subject: [PATCH 2/2] Adjust task definition to new standard --- ci/tasks/build-resource.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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