-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from pjagielski/saas_jenkins
SCM provider support
- Loading branch information
Showing
12 changed files
with
94 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package pl.touk.sputnik.configuration; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public enum Provider { | ||
|
||
GITHUB("github"), GITLAB("gitlab"); | ||
|
||
private final String name; | ||
|
||
Provider(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public static Provider from(String name) { | ||
if (StringUtils.isNoneBlank(name)) { | ||
return Provider.valueOf(name.toUpperCase()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
6 changes: 4 additions & 2 deletions
6
...tnik/connector/github/GithubPatchset.java → ...a/pl/touk/sputnik/connector/Patchset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
package pl.touk.sputnik.connector.github; | ||
package pl.touk.sputnik.connector; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import pl.touk.sputnik.configuration.Provider; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public class GithubPatchset { | ||
public class Patchset { | ||
private final Integer pullRequestId; | ||
private final String projectPath; | ||
private final Provider provider; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/pl/touk/sputnik/connector/PatchsetBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package pl.touk.sputnik.connector; | ||
|
||
import org.apache.commons.lang3.math.NumberUtils; | ||
import org.jetbrains.annotations.NotNull; | ||
import pl.touk.sputnik.configuration.CliOption; | ||
import pl.touk.sputnik.configuration.Configuration; | ||
import pl.touk.sputnik.configuration.GeneralOption; | ||
import pl.touk.sputnik.configuration.Provider; | ||
|
||
import static org.apache.commons.lang3.Validate.isTrue; | ||
import static org.apache.commons.lang3.Validate.notBlank; | ||
import static org.apache.commons.lang3.Validate.notNull; | ||
|
||
public final class PatchsetBuilder { | ||
|
||
private PatchsetBuilder() { } | ||
|
||
@NotNull | ||
public static Patchset build(Configuration configuration) { | ||
String pullRequestId = configuration.getProperty(CliOption.PULL_REQUEST_ID); | ||
String project = configuration.getProperty(GeneralOption.PROJECT); | ||
String repository = configuration.getProperty(GeneralOption.REPOSITORY); | ||
Provider provider = Provider.from(configuration.getProperty(CliOption.PROVIDER)); | ||
|
||
notBlank(pullRequestId, "You must provide non blank pull request id"); | ||
isTrue(NumberUtils.isNumber(pullRequestId), "Integer value as pull request id required"); | ||
notBlank(project, "You must provide non blank project key"); | ||
notBlank(repository, "You must provide non blank repository slug"); | ||
notNull(provider, "You must provide non blank SCM provider"); | ||
|
||
return new Patchset(Integer.parseInt(pullRequestId), String.format("%s/%s", project, repository), provider); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
src/main/java/pl/touk/sputnik/connector/github/GithubPatchsetBuilder.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters