mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-29 08:21:26 +00:00
Merge pull request #142 from suryagaddipati/master
Add code for creating deployments for a repo
This commit is contained in:
12
src/main/java/org/kohsuke/github/GHDeployment.java
Normal file
12
src/main/java/org/kohsuke/github/GHDeployment.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
public class GHDeployment {
|
||||
private GHRepository owner;
|
||||
private GitHub root;
|
||||
|
||||
GHDeployment wrap(GHRepository owner) {
|
||||
this.owner = owner;
|
||||
this.root = owner.root;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
32
src/main/java/org/kohsuke/github/GHDeploymentBuilder.java
Normal file
32
src/main/java/org/kohsuke/github/GHDeploymentBuilder.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GHDeploymentBuilder {
|
||||
private final GHRepository repo;
|
||||
private final Requester builder;
|
||||
|
||||
public GHDeploymentBuilder(GHRepository repo) {
|
||||
this.repo = repo;
|
||||
this.builder = new Requester(repo.root);
|
||||
}
|
||||
|
||||
public GHDeploymentBuilder ref(String branch) {
|
||||
builder.with("ref",branch);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GHDeploymentBuilder payload(String payload) {
|
||||
builder.with("payload",payload);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GHDeploymentBuilder description(String description) {
|
||||
builder.with("description",description);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GHDeployment create() throws IOException {
|
||||
return builder.to(repo.getApiTailUrl("deployments"),GHDeployment.class).wrap(repo);
|
||||
}
|
||||
}
|
||||
@@ -25,28 +25,15 @@ package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.net.URL;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.*;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
/**
|
||||
* A repository on GitHub.
|
||||
@@ -74,6 +61,10 @@ public class GHRepository {
|
||||
|
||||
private GHRepoPermission permissions;
|
||||
|
||||
public GHDeploymentBuilder createDeployment() {
|
||||
return new GHDeploymentBuilder(this);
|
||||
}
|
||||
|
||||
private static class GHRepoPermission {
|
||||
boolean pull,push,admin;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
import org.kohsuke.github.GHCommit.File;
|
||||
import org.kohsuke.github.GHOrganization.Permission;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
@@ -82,6 +76,19 @@ public class AppTest extends AbstractGitHubApiTestBase {
|
||||
o.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateDeployment() throws IOException {
|
||||
GHUser u = getUser();
|
||||
GHRepository repository = getTestRepository();
|
||||
//GHMilestone milestone = repository.createMilestone(System.currentTimeMillis() + "", "Test Milestone");
|
||||
GHDeployment o = repository.createDeployment()
|
||||
.ref("master")
|
||||
.payload("{\"user\":\"atmos\",\"room_id\":123456}")
|
||||
.description("question")
|
||||
.create();
|
||||
assertNotNull(o);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIssues() throws Exception {
|
||||
List<GHIssue> closedIssues = gitHub.getUser("kohsuke").getRepository("github-api").getIssues(GHIssueState.CLOSED);
|
||||
|
||||
Reference in New Issue
Block a user