update build specs
This commit is contained in:
parent
24b23e64e6
commit
2835b7c2c9
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.atlassian.bamboo</groupId>
|
<groupId>com.atlassian.bamboo</groupId>
|
||||||
<artifactId>bamboo-specs-parent</artifactId>
|
<artifactId>bamboo-specs-parent</artifactId>
|
||||||
<version>7.1.2</version>
|
<version>8.2.5</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|||||||
@ -34,164 +34,208 @@ import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties.Location;
|
|||||||
/**
|
/**
|
||||||
* Plan configuration for Bamboo.
|
* Plan configuration for Bamboo.
|
||||||
* Learn more on: <a href=
|
* Learn more on: <a href=
|
||||||
*
|
|
||||||
* "https://confluence.atlassian.com/display/BAMBOO/Bamboo+Specs">https://confluence.atlassian.com/display/BAMBOO/Bamboo+Specs</a>
|
* "https://confluence.atlassian.com/display/BAMBOO/Bamboo+Specs">https://confluence.atlassian.com/display/BAMBOO/Bamboo+Specs</a>
|
||||||
*/
|
*/
|
||||||
@BambooSpec
|
@BambooSpec
|
||||||
public class PlanSpec {
|
public class PlanSpec {
|
||||||
|
private static final String REPOSITORY_KEY = "RR";
|
||||||
|
// this is the repo name
|
||||||
|
private static final String SERVICE_NAME = "image-prediction";
|
||||||
|
private static final String SERVICE_KEY = SERVICE_NAME.toUpperCase().replaceAll("-", "").replaceAll("_", "");
|
||||||
|
private static final String PROJECT_NAME = "RED";
|
||||||
|
private static final String PROJECT_KEY = "RED";
|
||||||
|
private static final String HOST = "nexus.iqser.com";
|
||||||
|
private static final String PORT = "5001";
|
||||||
|
|
||||||
private static final String SERVICE_NAME = "image-prediction";
|
/**
|
||||||
|
* 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");
|
||||||
|
|
||||||
private static final String SERVICE_KEY = SERVICE_NAME.toUpperCase().replaceAll("-", "").replaceAll("_", "");
|
Plan plan = new PlanSpec().createDockerBuildPlan();
|
||||||
|
bambooServer.publish(plan);
|
||||||
|
PlanPermissions planPermission = new PlanSpec().createPlanPermission(plan.getIdentifier());
|
||||||
|
bambooServer.publish(planPermission);
|
||||||
|
|
||||||
/**
|
Plan secPlan = new PlanSpec().createSecBuild();
|
||||||
* Run main to publish plan on Bamboo
|
bambooServer.publish(secPlan);
|
||||||
*/
|
PlanPermissions secPlanPermission = new PlanSpec().createPlanPermission(secPlan.getIdentifier());
|
||||||
public static void main(final String[] args) throws Exception {
|
bambooServer.publish(secPlanPermission);
|
||||||
// By default credentials are read from the '.credentials' file.
|
}
|
||||||
BambooServer bambooServer = new BambooServer("http://localhost:8085");
|
|
||||||
|
|
||||||
Plan plan = new PlanSpec().createDockerBuildPlan();
|
private PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) {
|
||||||
bambooServer.publish(plan);
|
Permissions permission = new Permissions()
|
||||||
PlanPermissions planPermission = new PlanSpec().createPlanPermission(plan.getIdentifier());
|
.userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW,
|
||||||
bambooServer.publish(planPermission);
|
PermissionType.ADMIN,
|
||||||
|
PermissionType.CLONE, PermissionType.BUILD)
|
||||||
|
.groupPermissions("research", PermissionType.EDIT, PermissionType.VIEW,
|
||||||
|
PermissionType.CLONE,
|
||||||
|
PermissionType.BUILD)
|
||||||
|
.groupPermissions("Development", PermissionType.EDIT, PermissionType.VIEW,
|
||||||
|
PermissionType.CLONE,
|
||||||
|
PermissionType.BUILD)
|
||||||
|
.groupPermissions("QA", PermissionType.EDIT, PermissionType.VIEW, PermissionType.CLONE,
|
||||||
|
PermissionType.BUILD)
|
||||||
|
.loggedInUserPermissions(PermissionType.VIEW)
|
||||||
|
.anonymousUserPermissionView();
|
||||||
|
return new PlanPermissions(planIdentifier.getProjectKey(), planIdentifier.getPlanKey())
|
||||||
|
.permissions(permission);
|
||||||
|
}
|
||||||
|
|
||||||
Plan secPlan = new PlanSpec().createSecBuild();
|
private Project project() {
|
||||||
bambooServer.publish(secPlan);
|
return new Project()
|
||||||
PlanPermissions secPlanPermission = new PlanSpec().createPlanPermission(secPlan.getIdentifier());
|
.name(PROJECT_NAME)
|
||||||
bambooServer.publish(secPlanPermission);
|
.key(new BambooKey(PROJECT_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) {
|
public Plan createDockerBuildPlan() {
|
||||||
Permissions permission = new Permissions()
|
return new Plan(
|
||||||
|
project(),
|
||||||
|
SERVICE_NAME, new BambooKey(SERVICE_KEY))
|
||||||
|
.description("Docker build for " + SERVICE_NAME)
|
||||||
|
// .variables()
|
||||||
|
.stages(
|
||||||
|
new Stage("Sonar Stage")
|
||||||
|
.jobs(
|
||||||
|
new Job("Sonar Job", new BambooKey("SONAR"))
|
||||||
|
.tasks(
|
||||||
|
new CleanWorkingDirectoryTask()
|
||||||
|
.description("Clean working directory.")
|
||||||
|
.enabled(true),
|
||||||
|
new VcsCheckoutTask()
|
||||||
|
.description("Checkout default repository.")
|
||||||
|
.checkoutItems(new CheckoutItem().defaultRepository()),
|
||||||
|
new ScriptTask()
|
||||||
|
.description("Set config and keys.")
|
||||||
|
.location(Location.FILE)
|
||||||
|
.fileFromPath(
|
||||||
|
"bamboo-specs/src/main/resources/scripts/key-prepare.sh"),
|
||||||
|
new ScriptTask()
|
||||||
|
.description("Run Sonarqube scan.")
|
||||||
|
.location(Location.FILE)
|
||||||
|
.fileFromPath(
|
||||||
|
"bamboo-specs/src/main/resources/scripts/sonar-scan.sh")
|
||||||
|
.argument(SERVICE_NAME))
|
||||||
|
.dockerConfiguration(
|
||||||
|
new DockerConfiguration()
|
||||||
|
.image("nexus.iqser.com:5001/infra/release_build:4.2.0")
|
||||||
|
.volume("/var/run/docker.sock",
|
||||||
|
"/var/run/docker.sock"))),
|
||||||
|
new Stage("Build Stage")
|
||||||
|
.jobs(
|
||||||
|
new Job("Build Job", new BambooKey("BUILD"))
|
||||||
|
.tasks(
|
||||||
|
new CleanWorkingDirectoryTask()
|
||||||
|
.description("Clean working directory.")
|
||||||
|
.enabled(true),
|
||||||
|
new VcsCheckoutTask()
|
||||||
|
.description("Checkout default repository.")
|
||||||
|
.checkoutItems(new CheckoutItem()
|
||||||
|
.defaultRepository()),
|
||||||
|
new ScriptTask()
|
||||||
|
.description("Set config and keys.")
|
||||||
|
.location(Location.FILE)
|
||||||
|
.fileFromPath(
|
||||||
|
"bamboo-specs/src/main/resources/scripts/key-prepare.sh"),
|
||||||
|
new ScriptTask()
|
||||||
|
.description("Build Docker container.")
|
||||||
|
.location(Location.FILE)
|
||||||
|
.fileFromPath(
|
||||||
|
"bamboo-specs/src/main/resources/scripts/docker-build.sh")
|
||||||
|
.argument(SERVICE_NAME),
|
||||||
|
new InjectVariablesTask()
|
||||||
|
.description("Inject git tag.")
|
||||||
|
.path("git.tag")
|
||||||
|
.namespace("g")
|
||||||
|
.scope(InjectVariablesScope.LOCAL),
|
||||||
|
new VcsTagTask()
|
||||||
|
.description("${bamboo.g.gitTag}")
|
||||||
|
.tagName("${bamboo.g.gitTag}")
|
||||||
|
.defaultRepository())
|
||||||
|
.dockerConfiguration(
|
||||||
|
new DockerConfiguration()
|
||||||
|
.image(HOST + ":"
|
||||||
|
+ PORT
|
||||||
|
+ "/infra/release_build:4.5.0")
|
||||||
|
.volume("/var/run/docker.sock",
|
||||||
|
"/var/run/docker.sock"))),
|
||||||
|
new Stage("License Stage")
|
||||||
|
.jobs(
|
||||||
|
new Job("License Job", new BambooKey("LICENSE"))
|
||||||
|
.enabled(true)
|
||||||
|
.tasks(
|
||||||
|
new VcsCheckoutTask()
|
||||||
|
.description("Checkout default repository.")
|
||||||
|
.checkoutItems(new CheckoutItem()
|
||||||
|
.defaultRepository()),
|
||||||
|
new ScriptTask()
|
||||||
|
.description("Build licence.")
|
||||||
|
.location(Location.FILE)
|
||||||
|
.fileFromPath(
|
||||||
|
"bamboo-specs/src/main/resources/scripts/create-licence.sh"))
|
||||||
|
.dockerConfiguration(
|
||||||
|
new DockerConfiguration()
|
||||||
|
.image(HOST + ":"
|
||||||
|
+ PORT
|
||||||
|
+ "/infra/maven:3.6.2-jdk-13-3.0.0")
|
||||||
|
.volume("/etc/maven/settings.xml",
|
||||||
|
"/usr/share/maven/ref/settings.xml")
|
||||||
|
.volume("/var/run/docker.sock",
|
||||||
|
"/var/run/docker.sock"))))
|
||||||
|
.linkedRepositories(REPOSITORY_KEY + " / " + SERVICE_NAME)
|
||||||
|
.triggers(
|
||||||
|
new BitbucketServerTrigger())
|
||||||
|
.planBranchManagement(
|
||||||
|
new PlanBranchManagement()
|
||||||
|
.createForVcsBranch()
|
||||||
|
.delete(
|
||||||
|
new BranchCleanup()
|
||||||
|
.whenInactiveInRepositoryAfterDays(
|
||||||
|
14))
|
||||||
|
.notificationForCommitters());
|
||||||
|
}
|
||||||
|
|
||||||
.userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN,
|
public Plan createSecBuild() {
|
||||||
|
return new Plan(project(), SERVICE_NAME + "-Sec", new BambooKey(SERVICE_KEY + "SEC"))
|
||||||
|
.description("Security Analysis Plan")
|
||||||
|
.stages(new Stage("Default Stage").jobs(
|
||||||
|
new Job("Sonar Job", new BambooKey("SONAR"))
|
||||||
|
.enabled(true)
|
||||||
|
.tasks(
|
||||||
|
new CleanWorkingDirectoryTask()
|
||||||
|
.description("Clean working directory.")
|
||||||
|
.enabled(true),
|
||||||
|
new VcsCheckoutTask()
|
||||||
|
.description("Checkout default repository.")
|
||||||
|
.checkoutItems(new CheckoutItem()
|
||||||
|
.defaultRepository()),
|
||||||
|
new ScriptTask()
|
||||||
|
.description("Set config and keys.")
|
||||||
|
.location(Location.FILE)
|
||||||
|
.fileFromPath("bamboo-specs/src/main/resources/scripts/key-prepare.sh"),
|
||||||
|
new ScriptTask()
|
||||||
|
.description("Run Sonarqube scan.")
|
||||||
|
.location(Location.FILE)
|
||||||
|
.fileFromPath("bamboo-specs/src/main/resources/scripts/sonar-scan.sh")
|
||||||
|
.argument(SERVICE_NAME))
|
||||||
|
.dockerConfiguration(
|
||||||
|
new DockerConfiguration()
|
||||||
|
.image(HOST + ":" + PORT
|
||||||
|
+ "/infra/release_build:4.2.0")
|
||||||
|
.volume("/var/run/docker.sock",
|
||||||
|
"/var/run/docker.sock"))))
|
||||||
|
.linkedRepositories(REPOSITORY_KEY + " / " + SERVICE_NAME)
|
||||||
|
.triggers(
|
||||||
|
new ScheduledTrigger()
|
||||||
|
.scheduleOnceDaily(LocalTime.of(23, 00)))
|
||||||
|
.planBranchManagement(
|
||||||
|
new PlanBranchManagement()
|
||||||
|
.createForVcsBranchMatching("release.*")
|
||||||
|
.notificationForCommitters());
|
||||||
|
}
|
||||||
|
|
||||||
PermissionType.CLONE, PermissionType.BUILD)
|
|
||||||
|
|
||||||
.groupPermissions("research", PermissionType.EDIT, PermissionType.VIEW, PermissionType.
|
|
||||||
LONE,
|
|
||||||
PermissionType.BUILD)
|
|
||||||
.groupPermissions("Development", PermissionType.EDIT, PermissionType.VIEW, PermissionType.CLONE,
|
|
||||||
PermissionType.BUILD)
|
|
||||||
.groupPermissions("QA", PermissionType.EDIT, PermissionType.VIEW, PermissionType.CLONE,
|
|
||||||
PermissionType.BUILD)
|
|
||||||
.loggedInUserPermissions(PermissionType.VIEW)
|
|
||||||
.anonymousUserPermissionView();
|
|
||||||
return new PlanPermissions(planIdentifier.getProjectKey(), planIdentifier.getPlanKey()).permissions(permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Project project() {
|
|
||||||
return new Project()
|
|
||||||
.name("RED")
|
|
||||||
.key(new BambooKey("RED"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Plan createDockerBuildPlan() {
|
|
||||||
return new Plan(
|
|
||||||
project(),
|
|
||||||
SERVICE_NAME, new BambooKey(SERVICE_KEY))
|
|
||||||
.description("Docker build for image-prediction.")
|
|
||||||
.stages(
|
|
||||||
new Stage("Build Stage")
|
|
||||||
.jobs(
|
|
||||||
new Job("Build Job", new BambooKey("BUILD"))
|
|
||||||
.tasks(
|
|
||||||
new CleanWorkingDirectoryTask()
|
|
||||||
.description("Clean working directory.")
|
|
||||||
.enabled(true),
|
|
||||||
new VcsCheckoutTask()
|
|
||||||
.description("Checkout default repository.")
|
|
||||||
.checkoutItems(new CheckoutItem().defaultRepository()),
|
|
||||||
new ScriptTask()
|
|
||||||
.description("Set config and keys.")
|
|
||||||
.location(Location.FILE)
|
|
||||||
.fileFromPath(
|
|
||||||
"bamboo-specs/src/main/resources/scripts/key-prepare.sh"),
|
|
||||||
new ScriptTask()
|
|
||||||
.description("Build Docker container.")
|
|
||||||
.location(Location.FILE)
|
|
||||||
.fileFromPath(
|
|
||||||
"bamboo-specs/src/main/resources/scripts/docker-build.sh")
|
|
||||||
.argument(SERVICE_NAME),
|
|
||||||
new InjectVariablesTask()
|
|
||||||
.description("Inject git tag.")
|
|
||||||
.path("git.tag")
|
|
||||||
.namespace("g")
|
|
||||||
.scope(InjectVariablesScope.LOCAL),
|
|
||||||
new VcsTagTask()
|
|
||||||
.description("${bamboo.g.gitTag}")
|
|
||||||
.tagName("${bamboo.g.gitTag}")
|
|
||||||
.defaultRepository())
|
|
||||||
.dockerConfiguration(
|
|
||||||
new DockerConfiguration()
|
|
||||||
.image("nexus.iqser.com:5001/infra/release_build:4.5.0")
|
|
||||||
.volume("/var/run/docker.sock",
|
|
||||||
"/var/run/docker.sock")),
|
|
||||||
new Job("Licence Job", new BambooKey("LICENCE"))
|
|
||||||
.enabled(false)
|
|
||||||
.tasks(
|
|
||||||
new VcsCheckoutTask()
|
|
||||||
.description("Checkout default repository.")
|
|
||||||
.checkoutItems(new CheckoutItem().defaultRepository()),
|
|
||||||
new ScriptTask()
|
|
||||||
.description("Build licence.")
|
|
||||||
.location(Location.FILE)
|
|
||||||
.fileFromPath(
|
|
||||||
"bamboo-specs/src/main/resources/scripts/create-licence.sh"))
|
|
||||||
.dockerConfiguration(
|
|
||||||
new DockerConfiguration()
|
|
||||||
.image("nexus.iqser.com:5001/infra/maven:3.6.2-jdk-13-3.0.0")
|
|
||||||
.volume("/etc/maven/settings.xml",
|
|
||||||
"/usr/share/maven/ref/settings.xml")
|
|
||||||
.volume("/var/run/docker.sock",
|
|
||||||
"/var/run/docker.sock"))))
|
|
||||||
.linkedRepositories("RR / " + SERVICE_NAME)
|
|
||||||
.linkedRepositories("RR / redai_image")
|
|
||||||
.triggers(
|
|
||||||
|
|
||||||
new BitbucketServerTrigger())
|
|
||||||
nBranchManagement(
|
|
||||||
new P
|
|
||||||
.createForVcsBranch()
|
|
||||||
.delete(
|
|
||||||
new
|
|
||||||
|
|
||||||
.notificationForCommitters());
|
|
||||||
|
|
||||||
|
|
||||||
ld() {
|
|
||||||
ect(), SERVICE_NAME + "-
|
|
||||||
("Security Analysis Plan")
|
|
||||||
new Stage("Defau
|
|
||||||
Job("Sonar Job", new BambooKey("SON
|
|
||||||
.tasks(
|
|
||||||
new CleanWorkingDirectoryTask()
|
|
||||||
.des
|
|
||||||
|
|
||||||
new VcsChec
|
|
||||||
.description("Checkout default repos
|
|
||||||
.checkoutItems(new CheckoutItem().defaultRepository()),
|
|
||||||
new ScriptTask()
|
|
||||||
|
|
||||||
|
|
||||||
.fileFromPath("bamboo-specs/src/main/resources/scripts/key-prepare.sh"),
|
|
||||||
|
|
||||||
|
|
||||||
.location(Locati
|
|
||||||
.fileFromPath("bamboo-specs/src/main/resources/scripts/sonar-scan.sh")
|
|
||||||
.argument(SERVICE_NAME))
|
|
||||||
.dockerConfiguration(
|
|
||||||
new DockerConfiguration()
|
|
||||||
.image("nexus.iqser.com:5001/infra/release_build:4.2.0")
|
|
||||||
.volume("/var/run/docker.sock", "/var/run/docker.sock"))))
|
|
||||||
.linkedRepositories("RR / " + SERVICE_NAME)
|
|
||||||
.triggers(
|
|
||||||
new ScheduledTrigger()
|
|
||||||
.scheduleOnceDaily(LocalTime.of(23, 00)))
|
|
||||||
.planBranchManagement(
|
|
||||||
new PlanBranchManagement()
|
|
||||||
.createForVcsBranchMatching("release.*")
|
|
||||||
.notificationForCommitters());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user