Skip to content

Commit

Permalink
fix(artifacts): fix unconverted artifacts on triggers (#2001)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander committed Feb 16, 2018
1 parent d20be33 commit db815cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ allprojects {
group = "com.netflix.spinnaker.orca"

ext {
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.140.0'
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.142.1'
}

def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ public TaskResult execute(@Nonnull Stage stage) {
Artifact match = artifactResolver.resolveSingleArtifact(expectedArtifact, priorArtifacts, false);

if (match == null) {
return new TaskResult(ExecutionStatus.TERMINAL);
outputs.put("exception", "No artifact matching " + expectedArtifact + " found among " + priorArtifacts);
return new TaskResult(ExecutionStatus.TERMINAL, new HashMap<>(), outputs);
}

outputs.put("resolvedExpectedArtifacts", Collections.singletonList(expectedArtifact));
outputs.put("artifacts", Collections.singletonList(match));

return new TaskResult(ExecutionStatus.SUCCEEDED, outputs);
return new TaskResult(ExecutionStatus.SUCCEEDED, outputs, outputs);
}

@Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package com.netflix.spinnaker.orca.pipeline.util;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import com.netflix.spinnaker.kork.artifacts.model.ExpectedArtifact;
import com.netflix.spinnaker.orca.pipeline.model.Execution;
import com.netflix.spinnaker.orca.pipeline.model.Stage;
import com.netflix.spinnaker.orca.pipeline.model.StageContext;
import com.netflix.spinnaker.orca.pipeline.model.Trigger;
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository;
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository.ExecutionCriteria;
import lombok.Data;
Expand Down Expand Up @@ -98,7 +98,7 @@ List<Artifact> getAllArtifacts(@Nonnull Execution execution) {

// Get all artifacts in the parent pipeline's trigger; these artifacts go at the end of the list,
// after any that were emitted by the pipeline
List<Artifact> triggerArtifacts = execution.getTrigger().getArtifacts();
List<Artifact> triggerArtifacts = objectMapper.convertValue(execution.getTrigger().getArtifacts(), new TypeReference<List<Artifact>>() {});

emittedArtifacts.addAll(triggerArtifacts);

Expand Down Expand Up @@ -139,17 +139,17 @@ List<Artifact> getArtifactsForPipelineId(
@Nonnull String pipelineId,
@Nonnull ExecutionCriteria criteria
) {
return executionRepository
.retrievePipelinesForPipelineConfigId(pipelineId, criteria)
.subscribeOn(Schedulers.io())
.toSortedList(startTimeOrId)
.toBlocking()
.single()
.stream()
.map(Execution::getTrigger)
.map(Trigger::getArtifacts)
.findFirst()
.orElse(emptyList());
Execution execution = executionRepository
.retrievePipelinesForPipelineConfigId(pipelineId, criteria)
.subscribeOn(Schedulers.io())
.toSortedList(startTimeOrId)
.toBlocking()
.single()
.stream()
.findFirst()
.orElse(null);

return execution == null ? Collections.emptyList() : getAllArtifacts(execution);
}

public void resolveArtifacts(@Nonnull Map pipeline) {
Expand Down

0 comments on commit db815cb

Please sign in to comment.