Skip to content

Commit

Permalink
Write output file to tmp directory (#61)
Browse files Browse the repository at this point in the history
ksindi authored Apr 29, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 527fca1 commit 538eabf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pipeline.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package main
import (
"fmt"
"io/ioutil"
"os"

"github.com/mohae/deepcopy"
log "github.com/sirupsen/logrus"
@@ -63,12 +64,20 @@ func generatePipeline(steps []interface{}, projects []Project) *Pipeline {
}

func uploadPipeline(pipeline Pipeline) {
outfile := "pipeline_output.yml"
tmpFile, err := ioutil.TempFile(os.TempDir(), "buildpipe-")
if err != nil {
log.Fatalf("Cannot create temporary file: %s\n", err)
}
defer os.Remove(tmpFile.Name())

data, err := yaml.Marshal(&pipeline)

fmt.Printf("Pipeline:\n%s", string(data))

err = ioutil.WriteFile(tmpFile.Name(), data, 0644)
if err != nil {
log.Fatalf("Error writing outfile: %s\n", err)
}
err = ioutil.WriteFile(outfile, data, 0644)
execCommand("buildkite-agent", []string{"pipeline", "upload", outfile})

execCommand("buildkite-agent", []string{"pipeline", "upload", tmpFile.Name()})
}

0 comments on commit 538eabf

Please sign in to comment.