Skip to content

Commit

Permalink
with a trailing slash (#24)
Browse files Browse the repository at this point in the history
* with a trailing slash

* more elegant path join based on PR feedback

* unnecessary import

* use correct import!

* make save path after artifactobj created
  • Loading branch information
benbitrise authored Jul 1, 2021
1 parent 63a29bf commit 91166a6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strings"
"path/filepath"

"github.com/bitrise-io/go-steputils/stepconf"
"github.com/bitrise-io/go-steputils/tools"
Expand Down Expand Up @@ -106,7 +107,8 @@ func main() {
}

if build.Status != 0 {
if strings.TrimSpace(cfg.BuildArtifactsSavePath) != "" {
buildArtifactSaveDir := strings.TrimSpace(cfg.BuildArtifactsSavePath)
if buildArtifactSaveDir != "" {
artifactsResponse, err := build.GetBuildArtifacts(app)
if err != nil {
log.Warnf("failed to get build artifacts, error: %s", err)
Expand All @@ -116,12 +118,12 @@ func main() {
if err != nil {
log.Warnf("failed to get build artifact, error: %s", err)
}

downloadErr := artifactObj.Artifact.DownloadArtifact(strings.TrimSpace(cfg.BuildArtifactsSavePath) + artifactObj.Artifact.Title)
fullBuildArtifactsSavePath := filepath.Join(buildArtifactSaveDir, artifactObj.Artifact.Title)
downloadErr := artifactObj.Artifact.DownloadArtifact(fullBuildArtifactsSavePath)
if downloadErr != nil {
log.Warnf("failed to download artifact, error: %s", downloadErr)
}
log.Donef("Downloaded: " + artifactObj.Artifact.Title + " to path " + strings.TrimSpace(cfg.BuildArtifactsSavePath))
log.Donef("Downloaded: " + artifactObj.Artifact.Title + " to path " + fullBuildArtifactsSavePath)
}
}
}
Expand Down

0 comments on commit 91166a6

Please sign in to comment.