Skip to content

Commit

Permalink
feat(MPTv2): Support artifacts when executing v2 templated pipelines. (
Browse files Browse the repository at this point in the history
  • Loading branch information
jtk54 committed Mar 7, 2019
1 parent 6eafe07 commit 2f766c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Map<String, Object> generate(V2PipelineTemplate template, V2TemplateConfi

addNotifications(pipeline, template, configuration);
addParameters(pipeline, template, configuration);
addExpectedArtifacts(pipeline, template, configuration);
addTriggers(pipeline, template, configuration);
pipeline.put("templateVariables", configuration.getVariables());

Expand Down Expand Up @@ -89,6 +90,23 @@ private void addParameters(Map<String, Object> pipeline, V2PipelineTemplate temp
}
}

private void addExpectedArtifacts(Map<String, Object> pipeline, V2PipelineTemplate template, V2TemplateConfiguration configuration) {
if (configuration.getInherit().contains("expectedArtifacts")) {
pipeline.put(
"expectedArtifacts",
TemplateMerge.mergeDistinct(
(List<HashMap<String, Object>>) template.getPipeline().get("expectedArtifacts"),
configuration.getExpectedArtifacts()
)
);
} else {
pipeline.put(
"expectedArtifacts",
Optional.ofNullable(configuration.getExpectedArtifacts()).orElse(Collections.emptyList())
);
}
}

private void addTriggers(Map<String, Object> pipeline,
V2PipelineTemplate template,
V2TemplateConfiguration configuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ import com.netflix.spinnaker.security.AuthenticatedRequest
import groovy.util.logging.Slf4j
import javassist.NotFoundException
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.bind.annotation.*
import retrofit.RetrofitError
import retrofit.http.Query

Expand Down Expand Up @@ -189,6 +185,9 @@ class OperationsController {
pipeline = preprocessor.process(pipeline)
}

// Explicitly resolve artifacts after preprocessing to support artifacts in templated pipelines.
artifactResolver?.resolveArtifacts(pipeline)

if (pipeline.disabled) {
throw new InvalidRequestException("Pipeline is disabled and cannot be started.")
}
Expand Down

0 comments on commit 2f766c8

Please sign in to comment.