aboutsummaryrefslogtreecommitdiff
path: root/bamboo-specs/src/main/java/tutorial/PlanSpec.java
diff options
context:
space:
mode:
authorgabrielgio <gabriel.giovanini@pm.me>2020-07-22 15:40:31 +0200
committergabrielgio <gabriel.giovanini@pm.me>2020-07-22 15:40:31 +0200
commitd21bba62984a70c737632c7ca217c4e6bd5ab388 (patch)
tree4060d1923a9116c68b471172a421b5c4b35caf97 /bamboo-specs/src/main/java/tutorial/PlanSpec.java
parent25a14696757491e3173160fff8fd1e9b0c503c61 (diff)
downloadgenpass-d21bba62984a70c737632c7ca217c4e6bd5ab388.tar.gz
genpass-d21bba62984a70c737632c7ca217c4e6bd5ab388.tar.bz2
genpass-d21bba62984a70c737632c7ca217c4e6bd5ab388.zip
Adds bamboo specs
Diffstat (limited to 'bamboo-specs/src/main/java/tutorial/PlanSpec.java')
-rw-r--r--bamboo-specs/src/main/java/tutorial/PlanSpec.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/bamboo-specs/src/main/java/tutorial/PlanSpec.java b/bamboo-specs/src/main/java/tutorial/PlanSpec.java
new file mode 100644
index 0000000..7dfd5f3
--- /dev/null
+++ b/bamboo-specs/src/main/java/tutorial/PlanSpec.java
@@ -0,0 +1,58 @@
+package tutorial;
+
+import com.atlassian.bamboo.specs.api.BambooSpec;
+import com.atlassian.bamboo.specs.api.builders.plan.Plan;
+import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier;
+import com.atlassian.bamboo.specs.api.builders.project.Project;
+import com.atlassian.bamboo.specs.util.BambooServer;
+import com.atlassian.bamboo.specs.api.builders.permission.Permissions;
+import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
+import com.atlassian.bamboo.specs.api.builders.permission.PlanPermissions;
+
+/**
+ * Plan configuration for Bamboo.
+ * Learn more on: <a href="https://confluence.atlassian.com/display/BAMBOO/Bamboo+Specs">https://confluence.atlassian.com/display/BAMBOO/Bamboo+Specs</a>
+ */
+@BambooSpec
+public class PlanSpec {
+
+ /**
+ * Run main to publish plan on Bamboo
+ */
+ public static void main(final String[] args) throws Exception {
+ //By default credentials are read from the '.credentials' file.
+ BambooServer bambooServer = new BambooServer("http://localhost:8085");
+
+ Plan plan = new PlanSpec().createPlan();
+
+ bambooServer.publish(plan);
+
+ PlanPermissions planPermission = new PlanSpec().createPlanPermission(plan.getIdentifier());
+
+ bambooServer.publish(planPermission);
+ }
+
+ PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) {
+ Permissions permission = new Permissions()
+ .userPermissions("admin", PermissionType.ADMIN, PermissionType.CLONE, PermissionType.EDIT)
+ .groupPermissions("bamboo-admin", PermissionType.ADMIN)
+ .loggedInUserPermissions(PermissionType.VIEW)
+ .anonymousUserPermissionView();
+ return new PlanPermissions(planIdentifier.getProjectKey(), planIdentifier.getPlanKey()).permissions(permission);
+ }
+
+ Project project() {
+ return new Project()
+ .name("Project Name")
+ .key("PRJ");
+ }
+
+ Plan createPlan() {
+ return new Plan(
+ project(),
+ "Plan Name", "PLANKEY")
+ .description("Plan created from (enter repository url of your plan)");
+ }
+
+
+}