/
GitHubSCMSourceBuilder.java
55 lines (47 loc) · 1.47 KB
/
GitHubSCMSourceBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package org.jenkinsci.plugins.github_branch_source;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.scm.api.trait.SCMSourceBuilder;
/**
* @author Stephen Connolly
*/
public class GitHubSCMSourceBuilder extends SCMSourceBuilder<GitHubSCMSourceBuilder, GitHubSCMSource> {
@NonNull
private final String id;
private final String apiUri;
@NonNull
private final String repoOwner;
private String credentialsId;
public GitHubSCMSourceBuilder(@NonNull String id, @CheckForNull String apiUri, @CheckForNull String credentialsId,
@NonNull String repoOwner,@NonNull String repoName) {
super(GitHubSCMSource.class, repoName);
this.id = id;
this.apiUri = apiUri;
this.repoOwner = repoOwner;
}
@NonNull
public String id() {
return id;
}
public String apiUri() {
return apiUri;
}
@NonNull
public String repoOwner() {
return repoOwner;
}
public String credentialsId() {
return credentialsId;
}
public GitHubSCMSourceBuilder withCredentialsId(String credentialsId) {
this.credentialsId = credentialsId;
return this;
}
@NonNull
@Override
public GitHubSCMSource build() {
GitHubSCMSource result = new GitHubSCMSource(id, apiUri, credentialsId, repoOwner, projectName());
result.setTraits(traits());
return result;
}
}