Skip to content

Commit

Permalink
Replace environment variables in include parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mizzy committed Dec 19, 2016
1 parent 5b7ce1a commit 5fd4428
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"bytes"
"errors"
"io/ioutil"
"os"
"regexp"
"strings"
"sync"

log "github.com/Sirupsen/logrus"
Expand Down Expand Up @@ -118,6 +121,13 @@ func (p *Pipeline) Run(build, deploy bool) int {
}

func includeTasks(file string) (Tasks, error) {
re := regexp.MustCompile(`\$[A-Z1-9\-_]+`)
matches := re.FindAllString(file, -1)
for _, m := range matches {
env := os.Getenv(strings.TrimPrefix(m, "$"))
file = strings.Replace(file, m, env, -1)
}

data, err := ioutil.ReadFile(file)
tasks := Tasks{}
if err != nil {
Expand Down

0 comments on commit 5fd4428

Please sign in to comment.