2021-06-09 09:38:52 +02:00
|
|
|
package orchestrator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
type JenkinsConfigProvider struct{}
|
|
|
|
|
2021-06-25 10:50:56 +02:00
|
|
|
func (j *JenkinsConfigProvider) GetBranch() string {
|
|
|
|
return os.Getenv("GIT_BRANCH")
|
2021-06-09 09:38:52 +02:00
|
|
|
}
|
|
|
|
|
2021-06-25 10:50:56 +02:00
|
|
|
func (j *JenkinsConfigProvider) GetBuildUrl() string {
|
|
|
|
return os.Getenv("BUILD_URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *JenkinsConfigProvider) GetCommit() string {
|
|
|
|
return os.Getenv("GIT_COMMIT")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *JenkinsConfigProvider) GetRepoUrl() string {
|
|
|
|
return os.Getenv("GIT_URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (j *JenkinsConfigProvider) GetPullRequestConfig() PullRequestConfig {
|
2021-06-09 09:38:52 +02:00
|
|
|
return PullRequestConfig{
|
|
|
|
Branch: os.Getenv("CHANGE_BRANCH"),
|
|
|
|
Base: os.Getenv("CHANGE_TARGET"),
|
|
|
|
Key: os.Getenv("CHANGE_ID"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-25 10:50:56 +02:00
|
|
|
func (j *JenkinsConfigProvider) IsPullRequest() bool {
|
2021-06-09 09:38:52 +02:00
|
|
|
return truthy("CHANGE_ID")
|
|
|
|
}
|
|
|
|
|
|
|
|
func isJenkins() bool {
|
|
|
|
envVars := []string{"JENKINS_HOME", "JENKINS_URL"}
|
|
|
|
return areIndicatingEnvVarsSet(envVars)
|
|
|
|
}
|