Skip to content

Commit

Permalink
Add Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
KacperMalachowski committed Jan 2, 2025
1 parent 742717a commit 9a400fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cmd/image-builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
Prow CISystem = "Prow"
GithubActions CISystem = "GithubActions"
AzureDevOps CISystem = "AzureDevOps"
Jenkins CISystem = "Jenkins"
)

type Config struct {
Expand Down Expand Up @@ -155,6 +156,8 @@ func LoadGitStateConfig(ciSystem CISystem) (GitStateConfig, error) {
// Load from env specific for Github Actions
case GithubActions:
return loadGithubActionsGitState()
case Jenkins:
return loadJenksingGitState()
default:
// Unknown CI System, return error and empty git state
return GitStateConfig{}, fmt.Errorf("unknown ci system, got %s", ciSystem)
Expand Down Expand Up @@ -363,5 +366,11 @@ func determineUsedCISystem(envGetter func(key string) string, envLookup func(key
return AzureDevOps, nil
}

// JENKINS_HOME environment variable is set in Jenkins
_, isJenkins := envLookup("JENKINS_HOME")
if isJenkins {
return Jenkins, nil
}

return "", fmt.Errorf("cannot determine ci system: unknown system")
}
7 changes: 7 additions & 0 deletions cmd/image-builder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ func Test_determineCISystem(t *testing.T) {
},
ciSystem: GithubActions,
},
{
name: "detect running in jenkins",
env: mockEnv{
"JENKINS_HOME": "/some/absolute/path",
},
ciSystem: Jenkins,
},
{
name: "unknown ci system",
env: mockEnv{
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/kyma-project/test-infra

go 1.22.0
go 1.23

toolchain go1.23.0

require (
Expand Down

0 comments on commit 9a400fd

Please sign in to comment.