Skip to content

Commit

Permalink
Merge pull request #73 from lwander/factor-multiple-build-events
Browse files Browse the repository at this point in the history
Factor BuildEvent into BuildEvent and GitEvent
  • Loading branch information
robfletcher committed Mar 4, 2016
2 parents b20939b + 35113db commit 7deecc2
Show file tree
Hide file tree
Showing 11 changed files with 621 additions and 270 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright 2015 Netflix, Inc.
* Copyright 2016 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -15,36 +15,24 @@
*/


package com.netflix.spinnaker.echo.model
package com.netflix.spinnaker.echo.model.trigger

import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import groovy.transform.Canonical

@Canonical
@JsonIgnoreProperties(ignoreUnknown = true)
class BuildEvent {
class BuildEvent extends TriggerEvent {
Content content;
Details details;

public static final String BUILD_EVENT_TYPE = "build";
public static final String GIT_EVENT_TYPE = "git";
public static final String TYPE = "build";

@Canonical
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Content {
Project project;
String master;
String repoProject;
String slug;
String hash;
}

@Canonical
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Details {
String type;
String source;
}

@Canonical
Expand All @@ -66,23 +54,8 @@ class BuildEvent {
SUCCESS, UNSTABLE, BUILDING, ABORTED, FAILURE, NOT_BUILT
}

@JsonIgnore
public boolean isBuild() {
return details.getType().equals(BUILD_EVENT_TYPE);
}

@JsonIgnore
public boolean isGit() {
return details.getType().equals(GIT_EVENT_TYPE);
}

@JsonIgnore
public int getBuildNumber() {
return isBuild() ? content.getProject().getLastBuild().getNumber() : 0;
}

@JsonIgnore
public String getHash() {
return isGit() ? content.hash : null;
return content.getProject().getLastBuild().getNumber();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2016 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.model.trigger

class DockerEvent extends TriggerEvent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2016 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.model.trigger

import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import groovy.transform.Canonical

@Canonical
@JsonIgnoreProperties(ignoreUnknown = true)
class GitEvent extends TriggerEvent {
Content content;

public static final String TYPE = 'GIT';

@Canonical
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Content {
String repoProject;
String slug;
String hash;
String branch;
}

@JsonIgnore
public String getHash() {
return content.hash;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2016 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.echo.model.trigger

import com.netflix.spinnaker.echo.model.Metadata

abstract class TriggerEvent {
Metadata details
}

This file was deleted.

Loading

0 comments on commit 7deecc2

Please sign in to comment.