Skip to content

Commit 2f4d163

Browse files
authored
Merge pull request #31 from sonic-screwdriver-cd/upload-artifacts
feat: enable to upload artifacts
2 parents 6d5b787 + b9c5209 commit 2f4d163

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

store-cli.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ func makeURL(storeType, scope, key string) (*url.URL, error) {
8989
encoded := url.QueryEscape(key)
9090
path = "caches/" + scope + "s/" + scopeEnv + "/" + encoded
9191
case "artifact":
92-
path = "builds/" + os.Getenv("SD_BUILD_ID") + "/ARTIFACTS/" + key
92+
key = strings.TrimLeft(key, "./")
93+
encoded := url.QueryEscape(key)
94+
path = "builds/" + os.Getenv("SD_BUILD_ID") + "/ARTIFACTS/" + encoded
9395
case "log":
9496
path = "builds/" + os.Getenv("SD_BUILD_ID") + "-" + key
9597
default:

store-cli_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ func TestMakeURL(t *testing.T) {
7070
{"cache", "event", "/!-_.*'()&@:,.$=+?; space", "http://store.screwdriver.cd/v1/caches/events/499/%2F%21-_.%2A%27%28%29%26%40%3A%2C.%24%3D%2B%3F%3B+space"},
7171
{"artifact", "event", "artifact-1", "http://store.screwdriver.cd/v1/builds/10038/ARTIFACTS/artifact-1"},
7272
{"artifact", "build", "test", "http://store.screwdriver.cd/v1/builds/10038/ARTIFACTS/test"},
73+
{"artifact", "", "./test", "http://store.screwdriver.cd/v1/builds/10038/ARTIFACTS/test"},
74+
{"artifact", "", "test/foo", "http://store.screwdriver.cd/v1/builds/10038/ARTIFACTS/test%2Ffoo"},
75+
{"artifact", "", "test/foo./bar", "http://store.screwdriver.cd/v1/builds/10038/ARTIFACTS/test%2Ffoo.%2Fbar"},
76+
{"artifact", "", "test/foo/あいうえお.txt", "http://store.screwdriver.cd/v1/builds/10038/ARTIFACTS/test%2Ffoo%2F%E3%81%82%E3%81%84%E3%81%86%E3%81%88%E3%81%8A.txt"},
77+
{"artifact", "", "!-_.*'()&@:,.$=+?; space", "http://store.screwdriver.cd/v1/builds/10038/ARTIFACTS/%21-_.%2A%27%28%29%26%40%3A%2C.%24%3D%2B%3F%3B+space"},
7378
{"log", "build", "testlog", "http://store.screwdriver.cd/v1/builds/10038-testlog"},
7479
{"log", "build", "step-bookend", "http://store.screwdriver.cd/v1/builds/10038-step-bookend"},
7580
{"log", "pipeline", "test-2", "http://store.screwdriver.cd/v1/builds/10038-test-2"},

0 commit comments

Comments
 (0)