mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
911d4bc770
* Make sonarExecuteScan orchestrator-agnostic
* Increase coverage + support empty or false env vars
* Use cleared env for unit tests
* Refactor to standalone package
* Fix review findings
* Fix review findings
* Fix unit test
* Add logging
* Refactor
* Add to codeowners 😎
* Apply suggestions from code review
* Remove unreachable code
* no message
* fix typos
Co-authored-by: Christopher Fenner <26137398+CCFenner@users.noreply.github.com>
32 lines
813 B
Go
32 lines
813 B
Go
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)
|
|
}
|