Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Produce the current timestamp to invalidate the previous version so every build
- "$BUILD_PIPELINE_NAME" > build-pipeline-name
- "$BUILD_TEAM_NAME" > build-team-name
- "$ATC_EXTERNAL_URL" > atc-external-url
- "$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME" > build-url (this is a URL to the build)
- "$ATC_EXTERNAL_URL/builds/$BUILD_ID" > build-url-short (this is a shorter URL to the build)

#### Parameters

Expand Down
2 changes: 2 additions & 0 deletions in/in_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ var _ = Describe("In", func() {
checkProp(destination, "build-pipeline-name", "BUILD_PIPELINE_NAME", "4", response.Metadata[3])
checkProp(destination, "build-team-name", "BUILD_TEAM_NAME", "5", response.Metadata[4])
checkProp(destination, "atc-external-url", "ATC_EXTERNAL_URL", "6", response.Metadata[5])
checkProp(destination, "build-url", "BUILD_URL", "6/teams/5/pipelines/4/jobs/3/builds/2", response.Metadata[6])
checkProp(destination, "build-url-short", "BUILD_URL_SHORT", "6/builds/1", response.Metadata[7])
})

})
Expand Down
17 changes: 16 additions & 1 deletion in/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"net/url"
"os"
"path/filepath"

Expand All @@ -23,7 +24,7 @@ func main() {
fatal("creating destination", err)
}

meta := make(models.Metadata,6)
meta := make(models.Metadata,8)

var request models.InRequest

Expand All @@ -34,12 +35,26 @@ func main() {

var inVersion = request.Version

// pretend that Concourse set these metadata envvars (maybe it would be
// a good idea to implement them on the Concourse side?)
os.Setenv("BUILD_URL", fmt.Sprintf("%s/teams/%s/pipelines/%s/jobs/%s/builds/%s",
url.PathEscape(os.Getenv("ATC_EXTERNAL_URL")),
url.PathEscape(os.Getenv("BUILD_TEAM_NAME")),
url.PathEscape(os.Getenv("BUILD_PIPELINE_NAME")),
url.PathEscape(os.Getenv("BUILD_JOB_NAME")),
url.PathEscape(os.Getenv("BUILD_NAME"))))
os.Setenv("BUILD_URL_SHORT", fmt.Sprintf("%s/builds/%s",
url.PathEscape(os.Getenv("ATC_EXTERNAL_URL")),
url.PathEscape(os.Getenv("BUILD_ID"))))

handleProp(destination, "build-id", "BUILD_ID", meta, 0)
handleProp(destination, "build-name", "BUILD_NAME", meta, 1)
handleProp(destination, "build-job-name", "BUILD_JOB_NAME", meta, 2)
handleProp(destination, "build-pipeline-name", "BUILD_PIPELINE_NAME", meta, 3)
handleProp(destination, "build-team-name", "BUILD_TEAM_NAME", meta, 4)
handleProp(destination, "atc-external-url", "ATC_EXTERNAL_URL", meta, 5)
handleProp(destination, "build-url", "BUILD_URL", meta, 6)
handleProp(destination, "build-url-short", "BUILD_URL_SHORT", meta, 7)

json.NewEncoder(os.Stdout).Encode(models.InResponse{
Version: inVersion,
Expand Down