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/azureDevOps.go

32 lines
813 B
Go
Raw Normal View History

package orchestrator
import (
"os"
"strings"
)
type AzureDevOpsConfigProvider struct{}
func (a *AzureDevOpsConfigProvider) GetPullRequestConfig() PullRequestConfig {
return PullRequestConfig{
Branch: os.Getenv("SYSTEM_PULLREQUEST_SOURCEBRANCH"),
Base: os.Getenv("SYSTEM_PULLREQUEST_TARGETBRANCH"),
Key: os.Getenv("SYSTEM_PULLREQUEST_PULLREQUESTID"),
}
}
func (a *AzureDevOpsConfigProvider) GetBranchBuildConfig() BranchBuildConfig {
tmp := os.Getenv("BUILD_SOURCEBRANCH")
trimmed := strings.TrimPrefix(tmp, "refs/heads/")
return BranchBuildConfig{Branch: trimmed}
}
func (a *AzureDevOpsConfigProvider) IsPullRequest() bool {
return os.Getenv("BUILD_REASON") == "PullRequest"
}
func isAzure() bool {
envVars := []string{"AZURE_HTTP_USER_AGENT"}
return areIndicatingEnvVarsSet(envVars)
}