Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(artifacts): Resolve expectedArtifact by ids in trigger. #1763

Merged
merged 1 commit into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ allprojects {
group = "com.netflix.spinnaker.orca"

ext {
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.117.0'
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.120.0'
}

def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,20 @@ class AppEngineServerGroupCreator implements ServerGroupCreator {
return
}

Map expectedArtifact = operation.expectedArtifact
String expectedArtifactId = operation.expectedArtifactId
Execution execution = stage.getExecution()

Map expectedArtifact = [:]
Map<String, Object> trigger = [:]
if (execution instanceof Pipeline) {
// TODO(jacobkiefer): Use stage context input/output lookup.
trigger = ((Pipeline) execution).getTrigger()
expectedArtifact = trigger.resolvedExpectedArtifacts.find { e -> e.id == expectedArtifactId } as Map
}

// NOTE: expectedArtifact is a Map, and fragile to field changes in the underlying data structures.
// If a field changes in the ExpectedArtifact model, change it here.
if (operation.fromArtifact && expectedArtifact && expectedArtifact.matchArtifact) {
Execution execution = stage.getExecution()
Map<String, Object> trigger = [:]
if (execution instanceof Pipeline) {
trigger = ((Pipeline) execution).getTrigger()
}

List<Map> artifacts = (List<Map>) trigger.artifacts
def foundArtifact = artifacts.find { a ->
ExpectedArtifact e = objectMapper.convertValue(expectedArtifact, ExpectedArtifact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ArtifactResolver {
static void resolveArtifacts(Map pipeline) {
Set<Artifact> resolvedArtifacts = []
List<Artifact> receivedArtifacts = pipeline.receivedArtifacts ?: []
List<ExpectedArtifact> expectedArtifacts = pipeline.trigger.expectedArtifacts ?: []
List<ExpectedArtifact> expectedArtifacts = pipeline.expectedArtifacts.findAll { e -> e.id in pipeline.trigger.expectedArtifactIds } ?: []
List<ExpectedArtifact> unresolvedExpectedArtifacts = []

for (ExpectedArtifact expectedArtifact : expectedArtifacts) {
Expand Down Expand Up @@ -56,12 +56,12 @@ class ArtifactResolver {
}

pipeline.trigger.artifacts = resolvedArtifacts as List
pipeline.trigger.resolvedExpectedArtifacts = expectedArtifacts // Add the actual expectedArtifacts we included in the ids.
}

static class ArtifactResolutionException extends RuntimeException {
ArtifactResolutionException(String message) {
super(message)
}

}
}