Skip to content

Commit

Permalink
feat(igor): Back the default script stage job by a dynamic/fast prope…
Browse files Browse the repository at this point in the history
…rty (spinnaker#3942)

Supports `defaultJob` being changed on-the-fly without a service restart.
  • Loading branch information
ajordens authored Oct 3, 2020
1 parent 59c995f commit 4f6eac3
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
package com.netflix.spinnaker.orca.igor.tasks

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.kork.exceptions.IntegrationException
import com.netflix.spinnaker.kork.exceptions.SystemException
import com.netflix.spinnaker.orca.api.pipeline.RetryableTask
import com.netflix.spinnaker.orca.api.pipeline.models.ExecutionStatus
import com.netflix.spinnaker.orca.api.pipeline.Task
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution
import com.netflix.spinnaker.orca.api.pipeline.TaskResult
import com.netflix.spinnaker.orca.exceptions.ExceptionHandler
Expand All @@ -31,6 +29,7 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.core.env.Environment
import org.springframework.http.HttpStatus
import org.springframework.stereotype.Component
import retrofit.RetrofitError
Expand All @@ -52,12 +51,12 @@ class StartScriptTask implements RetryableTask {
@Autowired
RetrofitExceptionHandler retrofitExceptionHandler

@Autowired
Environment environment

@Value('${script.master:master}')
String master

@Value('${script.job:job}')
String defaultJob

@Nonnull
@Override
TaskResult execute(@Nonnull StageExecution stage) {
Expand All @@ -70,7 +69,7 @@ class StartScriptTask implements RetryableTask {
String cmc = stage.context.cmc
String repoUrl = stage.context.repoUrl
String repoBranch = stage.context.repoBranch
String job = stage.context.job ?: defaultJob
String job = stage.context.job ?: getDefaultJob()

if (stage.execution.trigger.strategy) {
def trigger = stage.execution.trigger
Expand Down Expand Up @@ -137,4 +136,8 @@ class StartScriptTask implements RetryableTask {
long getTimeout() {
return Duration.ofMinutes(15).toMillis()
}

private String getDefaultJob() {
return environment.getProperty("script.job", String, "job")
}
}

0 comments on commit 4f6eac3

Please sign in to comment.