Skip to content

Commit

Permalink
feat(artifacts): Add receivedArtifacts to Pipeline model. (#1648)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtk54 authored Sep 27, 2017
1 parent 7bc62e9 commit 0d9a2f1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 deletions.
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.109.2'
spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.110.5'
}

def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion]
Expand Down
1 change: 1 addition & 0 deletions orca-core/orca-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies {
compile spinnaker.dependency('spectatorApi')
compile spinnaker.dependency('kork')
compile spinnaker.dependency('korkExceptions')
compile spinnaker.dependency('korkArtifacts')
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${spinnaker.version('jackson')}"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${spinnaker.version('jackson')}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

package com.netflix.spinnaker.orca.pipeline;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.orca.pipeline.model.Execution;
Expand All @@ -28,6 +24,12 @@
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import static java.lang.Boolean.parseBoolean;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@

package com.netflix.spinnaker.orca.pipeline;

import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import com.netflix.spinnaker.orca.pipeline.model.Execution.ExecutionEngine;
import com.netflix.spinnaker.orca.pipeline.model.Pipeline;
import com.netflix.spinnaker.orca.pipeline.persistence.ExecutionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@Component
public class PipelineLauncher extends ExecutionLauncher<Pipeline> {

Expand Down Expand Up @@ -65,6 +67,7 @@ public PipelineLauncher(ObjectMapper objectMapper,
.withNotifications((List<Map<String, Object>>) config.get("notifications"))
.withExecutionEngine(getEnum(config, "executionEngine", ExecutionEngine.class))
.withOrigin(getString(config, "origin"))
.withReceivedArtifacts((List<Artifact>) config.get("receivedArtifacts"))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.spectator.api.Registry;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;

public class Pipeline extends Execution<Pipeline> {

Expand All @@ -42,6 +43,19 @@ public Pipeline(

private String pipelineConfigId;

/**
* Artifacts produced from trigger events and injected into the pipeline context.
*/
private List<Artifact> receivedArtifacts = new ArrayList<>();

public void setReceivedArtifacts(List<Artifact> receivedArtifacts) {
this.receivedArtifacts = receivedArtifacts;
}

public @Nonnull List<Artifact> getReceivedArtifacts() {
return receivedArtifacts;
}

public @Nullable String getPipelineConfigId() {
return pipelineConfigId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ class PipelineBuilder {
return this
}

PipelineBuilder withReceivedArtifacts(List receivedArtifacts = []) {
pipeline.receivedArtifacts.clear()
if (receivedArtifacts) {
pipeline.receivedArtifacts.addAll(receivedArtifacts)
}
return this
}

PipelineBuilder withNotifications(List<Map<String, Object>> notifications = []) {
pipeline.notifications.clear()
if (notifications) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ class JedisExecutionRepository implements ExecutionRepository {
map.pipelineConfigId = execution.pipelineConfigId
map.trigger = mapper.writeValueAsString(execution.trigger)
map.notifications = mapper.writeValueAsString(execution.notifications)
map.receivedArtifacts = mapper.writeValueAsString(execution.receivedArtifacts)
map.initialConfig = mapper.writeValueAsString(execution.initialConfig)
} else if (execution instanceof Orchestration) {
map.description = execution.description
Expand Down Expand Up @@ -653,6 +654,7 @@ class JedisExecutionRepository implements ExecutionRepository {
execution.pipelineConfigId = map.pipelineConfigId
execution.trigger.putAll(mapper.readValue(map.trigger, Map))
execution.notifications.addAll(mapper.readValue(map.notifications, List))
execution.receivedArtifacts.addAll(mapper.readValue(map.receivedArtifacts, List))
execution.initialConfig.putAll(mapper.readValue(map.initialConfig, Map))
} else if (execution instanceof Orchestration) {
execution.description = map.description
Expand Down

1 comment on commit 0d9a2f1

@robzienert
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit broke in-flight pipelines:

Failed to retrieve execution 'b1db7876-261a-4cb8-a05a-71d06fd3eef2', message: null
java.lang.NullPointerException: null
	at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.skipUTF8BOM(ByteSourceJsonBootstrapper.java:187)
	at com.fasterxml.jackson.core.JsonFactory._createParser(JsonFactory.java:1336)
	at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:921)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2973)
	at com.fasterxml.jackson.databind.ObjectMapper$readValue$1.call(Unknown Source)
	at com.netflix.spinnaker.orca.pipeline.persistence.jedis.JedisExecutionRepository.retrieveInternal(JedisExecutionRepository.groovy:657)
	at sun.reflect.GeneratedMethodAccessor211.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
	at com.netflix.spinnaker.orca.pipeline.persistence.jedis.JedisExecutionRepository$_retrieveObservable_closure30$_closure48$_closure49.doCall(JedisExecutionRepository.groovy:727)
	at sun.reflect.GeneratedMethodAccessor210.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
	at groovy.lang.Closure.call(Closure.java:414)
	at org.codehaus.groovy.runtime.ConvertedClosure.invokeCustom(ConvertedClosure.java:54)
	at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:124)
	at com.sun.proxy.$Proxy175.apply(Unknown Source)
	at sun.reflect.GeneratedMethodAccessor206.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1080)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
	at groovy.lang.Closure.call(Closure.java:414)
	at groovy.lang.Closure.call(Closure.java:430)
	at org.codehaus.groovy.runtime.IOGroovyMethods.withCloseable(IOGroovyMethods.java:1622)
	at org.codehaus.groovy.runtime.NioGroovyMethods.withCloseable(NioGroovyMethods.java:1754)
	at sun.reflect.GeneratedMethodAccessor202.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54)
	at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:56)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at com.netflix.spinnaker.orca.pipeline.persistence.jedis.JedisExecutionRepository.withJedis(JedisExecutionRepository.groovy:810)
	at sun.reflect.GeneratedMethodAccessor208.invoke(Unknown Source)

Please sign in to comment.