This repository was archived by the owner on Jul 31, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
main/java/org/kohsuke/github
test/java/org/kohsuke/github Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .kohsuke .github ;
2+
3+ public class GHDeployment {
4+ private GHRepository owner ;
5+ private GitHub root ;
6+
7+ GHDeployment wrap (GHRepository owner ) {
8+ this .owner = owner ;
9+ this .root = owner .root ;
10+ return this ;
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ package org .kohsuke .github ;
2+
3+ import java .io .IOException ;
4+
5+ public class GHDeploymentBuilder {
6+ private final GHRepository repo ;
7+ private final Requester builder ;
8+
9+ public GHDeploymentBuilder (GHRepository repo ) {
10+ this .repo = repo ;
11+ this .builder = new Requester (repo .root );
12+ }
13+
14+ public GHDeploymentBuilder ref (String branch ) {
15+ builder .with ("ref" ,branch );
16+ return this ;
17+ }
18+
19+ public GHDeploymentBuilder payload (String payload ) {
20+ builder .with ("payload" ,payload );
21+ return this ;
22+ }
23+
24+ public GHDeploymentBuilder description (String description ) {
25+ builder .with ("description" ,description );
26+ return this ;
27+ }
28+
29+ public GHDeployment create () throws IOException {
30+ return builder .to (repo .getApiTailUrl ("deployments" ),GHDeployment .class ).wrap (repo );
31+ }
32+ }
Original file line number Diff line number Diff line change 2525
2626import com .fasterxml .jackson .annotation .JsonProperty ;
2727import com .infradna .tool .bridge_method_injector .WithBridgeMethods ;
28- import java .io .FileNotFoundException ;
2928
3029import javax .xml .bind .DatatypeConverter ;
30+ import java .io .FileNotFoundException ;
3131import java .io .IOException ;
3232import java .io .InterruptedIOException ;
3333import java .net .URL ;
34- import java .util .AbstractSet ;
35- import java .util .ArrayList ;
36- import java .util .Arrays ;
37- import java .util .Collection ;
38- import java .util .Collections ;
39- import java .util .Date ;
40- import java .util .HashMap ;
41- import java .util .HashSet ;
42- import java .util .Iterator ;
43- import java .util .List ;
44- import java .util .Locale ;
45- import java .util .Map ;
46- import java .util .Set ;
47- import java .util .TreeMap ;
48-
49- import static java .util .Arrays .*;
34+ import java .util .*;
35+
36+ import static java .util .Arrays .asList ;
5037
5138/**
5239 * A repository on GitHub.
@@ -74,6 +61,10 @@ public class GHRepository {
7461
7562 private GHRepoPermission permissions ;
7663
64+ public GHDeploymentBuilder createDeployment () {
65+ return new GHDeploymentBuilder (this );
66+ }
67+
7768 private static class GHRepoPermission {
7869 boolean pull ,push ,admin ;
7970 }
Original file line number Diff line number Diff line change 11package org .kohsuke .github ;
22
3- import java .io .IOException ;
4- import java .net .URL ;
5- import java .util .ArrayList ;
6- import java .util .Date ;
7- import java .util .List ;
8- import java .util .Map ;
9- import java .util .Map .Entry ;
10- import java .util .Set ;
11- import java .util .UUID ;
12-
3+ import com .google .common .base .Predicate ;
4+ import com .google .common .collect .Iterables ;
135import org .junit .Assume ;
146import org .junit .Test ;
157import org .kohsuke .github .GHCommit .File ;
168import org .kohsuke .github .GHOrganization .Permission ;
179
18- import com .google .common .base .Predicate ;
19- import com .google .common .collect .Iterables ;
10+ import java .io .IOException ;
11+ import java .net .URL ;
12+ import java .util .*;
13+ import java .util .Map .Entry ;
2014
2115/**
2216 * Unit test for simple App.
@@ -82,6 +76,19 @@ public void testCreateIssue() throws IOException {
8276 o .close ();
8377 }
8478
79+ @ Test
80+ public void testCreateDeployment () throws IOException {
81+ GHUser u = getUser ();
82+ GHRepository repository = getTestRepository ();
83+ //GHMilestone milestone = repository.createMilestone(System.currentTimeMillis() + "", "Test Milestone");
84+ GHDeployment o = repository .createDeployment ()
85+ .ref ("master" )
86+ .payload ("{\" user\" :\" atmos\" ,\" room_id\" :123456}" )
87+ .description ("question" )
88+ .create ();
89+ assertNotNull (o );
90+ }
91+
8592 @ Test
8693 public void testGetIssues () throws Exception {
8794 List <GHIssue > closedIssues = gitHub .getUser ("kohsuke" ).getRepository ("github-api" ).getIssues (GHIssueState .CLOSED );
You can’t perform that action at this time.
0 commit comments