1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/orchestrator/jenkins.go

41 lines
851 B
Go
Raw Normal View History

package orchestrator
import (
"os"
)
type JenkinsConfigProvider struct{}
func (j *JenkinsConfigProvider) GetBranch() string {
return os.Getenv("GIT_BRANCH")
}
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 {
return PullRequestConfig{
Branch: os.Getenv("CHANGE_BRANCH"),
Base: os.Getenv("CHANGE_TARGET"),
Key: os.Getenv("CHANGE_ID"),
}
}
func (j *JenkinsConfigProvider) IsPullRequest() bool {
return truthy("CHANGE_ID")
}
func isJenkins() bool {
envVars := []string{"JENKINS_HOME", "JENKINS_URL"}
return areIndicatingEnvVarsSet(envVars)
}