1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

feat(commonPipelineEnv): consume pipeline environment from env variable if set (#2919)

Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
This commit is contained in:
Kevin Stiehl 2021-06-17 16:54:57 +02:00 committed by GitHub
parent 80974ea930
commit 29b991d6fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,13 +31,21 @@ func WritePipelineEnv() *cobra.Command {
}
func runWritePipelineEnv() error {
inBytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return err
pipelineEnv, ok := os.LookupEnv("PIPER_pipelineEnv")
inBytes := []byte(pipelineEnv)
if !ok {
var err error
inBytes, err = ioutil.ReadAll(os.Stdin)
if err != nil {
return err
}
}
if len(inBytes) == 0 {
return nil
}
commonPipelineEnv := piperenv.CPEMap{}
err = json.Unmarshal(inBytes, &commonPipelineEnv)
err := json.Unmarshal(inBytes, &commonPipelineEnv)
if err != nil {
return err
}