Add codefresh CI detection. Thanks to @fernandocarletti. (#3270)
* Add codefresh CI detection. Thanks to @fernandocarletti.
This commit is contained in:
parent
a128b613ac
commit
4404dfb470
|
@ -14,6 +14,7 @@ CHANGELOG
|
|||
- Avoid re-encrypting secret values on each checkpoint write. These changes should improve update times for stacks
|
||||
that contain secret values.
|
||||
[#3183](https://github.com/pulumi/pulumi/pull/3183)
|
||||
- Add Codefresh CI detection.
|
||||
|
||||
## 1.1.0 (2019-09-11)
|
||||
|
||||
|
|
43
pkg/util/ciutil/codefresh.go
Normal file
43
pkg/util/ciutil/codefresh.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright 2016-2019, Pulumi Corporation.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package ciutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// codefreshCI represents the Codefresh CI system.
|
||||
type codefreshCI struct {
|
||||
baseCI
|
||||
}
|
||||
|
||||
// DetectVars detects the env vars for a Codefresh CI system.
|
||||
func (c codefreshCI) DetectVars() Vars {
|
||||
v := Vars{Name: c.Name}
|
||||
v.BuildID = os.Getenv("CF_BUILD_ID")
|
||||
v.BuildURL = os.Getenv("CF_BUILD_URL")
|
||||
v.SHA = os.Getenv("CF_REVISION")
|
||||
v.BranchName = os.Getenv("CF_BRANCH")
|
||||
v.CommitMessage = os.Getenv("CF_COMMIT_MESSAGE")
|
||||
v.PRNumber = os.Getenv("CF_PULL_REQUEST_NUMBER")
|
||||
|
||||
if v.PRNumber == "" {
|
||||
v.BuildType = "PullRequest"
|
||||
} else {
|
||||
v.BuildType = "Push"
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
|
@ -58,6 +58,12 @@ var detectors = map[SystemName]system{
|
|||
EnvVarsToDetect: []string{"CIRCLECI"},
|
||||
},
|
||||
},
|
||||
Codefresh: codefreshCI{
|
||||
baseCI: baseCI{
|
||||
Name: Codefresh,
|
||||
EnvVarsToDetect: []string{"CF_BUILD_URL"},
|
||||
},
|
||||
},
|
||||
Codeship: baseCI{
|
||||
Name: Codeship,
|
||||
EnvValuesToDetect: map[string]string{"CI_NAME": "codeship"},
|
||||
|
|
|
@ -27,6 +27,7 @@ const (
|
|||
AzurePipelines SystemName = "Azure Pipelines"
|
||||
Buildkite SystemName = "Buildkite"
|
||||
CircleCI SystemName = "CircleCI"
|
||||
Codefresh SystemName = "Codefresh"
|
||||
Codeship SystemName = "Codeship"
|
||||
Drone SystemName = "Drone"
|
||||
|
||||
|
|
|
@ -38,6 +38,11 @@ func TestDetectVars(t *testing.T) {
|
|||
"CIRCLECI": "true",
|
||||
"CIRCLE_BUILD_NUM": buildID,
|
||||
},
|
||||
Codefresh: {
|
||||
"TRAVIS": "",
|
||||
"CF_BUILD_URL": "https://g.codefresh.io/build/99f5d825577e23c56f8c6b2a",
|
||||
"CF_BUILD_ID": buildID,
|
||||
},
|
||||
GenericCI: {
|
||||
"TRAVIS": "",
|
||||
"PULUMI_CI_SYSTEM": "generic-ci-system",
|
||||
|
|
Loading…
Reference in a new issue