updated planspec

This commit is contained in:
Timo 2021-05-04 13:43:29 +03:00
parent cb8642cc13
commit 7bd9a2bf98
3 changed files with 52 additions and 36 deletions

2
.gitignore vendored
View File

@ -37,3 +37,5 @@ testem.log
# System Files # System Files
.DS_Store .DS_Store
Thumbs.db Thumbs.db
version.properties

View File

@ -14,11 +14,7 @@ import com.atlassian.bamboo.specs.api.builders.plan.artifact.Artifact;
import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup; import com.atlassian.bamboo.specs.api.builders.plan.branches.BranchCleanup;
import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement; import com.atlassian.bamboo.specs.api.builders.plan.branches.PlanBranchManagement;
import com.atlassian.bamboo.specs.api.builders.project.Project; import com.atlassian.bamboo.specs.api.builders.project.Project;
import com.atlassian.bamboo.specs.builders.task.CheckoutItem; import com.atlassian.bamboo.specs.builders.task.*;
import com.atlassian.bamboo.specs.builders.task.ScriptTask;
import com.atlassian.bamboo.specs.builders.task.TestParserTask;
import com.atlassian.bamboo.specs.builders.task.VcsCheckoutTask;
import com.atlassian.bamboo.specs.builders.task.VcsCommitTask;
import com.atlassian.bamboo.specs.builders.trigger.BitbucketServerTrigger; import com.atlassian.bamboo.specs.builders.trigger.BitbucketServerTrigger;
import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties; import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
import com.atlassian.bamboo.specs.util.BambooServer; import com.atlassian.bamboo.specs.util.BambooServer;
@ -51,10 +47,8 @@ public class PlanSpec {
private PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) { private PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) {
Permissions permission = new Permissions() Permissions permission = new Permissions()
.userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN, .userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN, PermissionType.CLONE, PermissionType.BUILD)
PermissionType.CLONE, PermissionType.BUILD) .userPermissions("tbejan", PermissionType.ADMIN, PermissionType.EDIT, PermissionType.VIEW, PermissionType.CLONE, PermissionType.BUILD)
.userPermissions("tbejan", PermissionType.ADMIN, PermissionType.EDIT, PermissionType.VIEW,
PermissionType.CLONE, PermissionType.BUILD)
.groupPermissions("red-ui", PermissionType.EDIT, PermissionType.VIEW, PermissionType.BUILD) .groupPermissions("red-ui", PermissionType.EDIT, PermissionType.VIEW, PermissionType.BUILD)
.loggedInUserPermissions(PermissionType.VIEW).anonymousUserPermissionView(); .loggedInUserPermissions(PermissionType.VIEW).anonymousUserPermissionView();
return new PlanPermissions(planIdentifier.getProjectKey(), planIdentifier.getPlanKey()).permissions(permission); return new PlanPermissions(planIdentifier.getProjectKey(), planIdentifier.getPlanKey()).permissions(permission);
@ -66,16 +60,21 @@ public class PlanSpec {
public Plan createDockerBuildPlan() { public Plan createDockerBuildPlan() {
return new Plan(project(), "Redaction UI", new BambooKey("UI")) return new Plan(project(), "Redaction UI", new BambooKey("UI"))
.description("Docker build for Redaction UI.").stages( .description("Docker build for Redaction UI.")
new Stage("Build Stage").jobs(creatGinCloudPlatformImagesJob("red-ui"))) .stages(new Stage("Build Stage").jobs(creatGinCloudPlatformImagesJob("red-ui")))
.stages(new Stage("Upstream Push Stage").jobs(creatGinCloudPlatformUpstreamJob())) .stages(new Stage("Upstream Push Stage")
.linkedRepositories("RED / ui").triggers(new BitbucketServerTrigger()).planBranchManagement( .jobs(creatGinCloudPlatformUpstreamJob()))
new PlanBranchManagement().createForVcsBranch() .stages(new Stage("Release")
.manual(true)
.jobs(createRelease()))
.linkedRepositories("RED / ui")
.triggers(new BitbucketServerTrigger()).planBranchManagement(new PlanBranchManagement().createForVcsBranch()
.delete(new BranchCleanup().whenInactiveInRepositoryAfterDays(30)).notificationForCommitters()); .delete(new BranchCleanup().whenInactiveInRepositoryAfterDays(30)).notificationForCommitters());
} }
public Job creatGinCloudPlatformImagesJob(String project) { public Job creatGinCloudPlatformImagesJob(String project) {
return new Job("Build Job: " + project, new BambooKey(project.toUpperCase().replaceAll("-", ""))).tasks( return new Job("Build Job: " + project, new BambooKey(project.toUpperCase().replaceAll("-", "")))
.tasks(
new VcsCheckoutTask().description("Checkout Default Repository") new VcsCheckoutTask().description("Checkout Default Repository")
.checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask().description("Build") .checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask().description("Build")
.location(ScriptTaskProperties.Location.FILE) .location(ScriptTaskProperties.Location.FILE)
@ -89,15 +88,28 @@ public class PlanSpec {
.volume("/var/run/docker.sock", "/var/run/docker.sock")); .volume("/var/run/docker.sock", "/var/run/docker.sock"));
} }
public Job creatGinCloudPlatformUpstreamJob() { public Job creatGinCloudPlatformUpstreamJob() {
return new Job("Upstream Push", new BambooKey("USPSH")).tasks( return new Job("Upstream Push", new BambooKey("USPSH"))
.tasks(
new VcsCheckoutTask().description("Checkout Default Repository") new VcsCheckoutTask().description("Checkout Default Repository")
.checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask().description("Build") .checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask().description("Build")
.location(ScriptTaskProperties.Location.FILE) .location(ScriptTaskProperties.Location.FILE)
.fileFromPath("bamboo-specs/src/main/resources/scripts/update-version.sh") .fileFromPath("bamboo-specs/src/main/resources/scripts/update-version.sh")
.environmentVariables("BRANCH_NAME=\"${bamboo.planRepository.branchName}\""), .environmentVariables("BRANCH_NAME=\"${bamboo.planRepository.branchName}\""),
new VcsCommitTask().commitMessage("chore(release)").repository("RED / ui")).dockerConfiguration( new VcsCommitTask().commitMessage("chore(release)").repository("RED / ui"))
new DockerConfiguration().image("nexus.iqser.com:5001/infra/release_build:2.9.1") .dockerConfiguration(new DockerConfiguration().image("nexus.iqser.com:5001/infra/release_build:2.9.1")
.volume("/var/run/docker.sock", "/var/run/docker.sock"));
}
public Job createRelease() {
return new Job("Create Release", new BambooKey("CRLS"))
.tasks(
new VcsCheckoutTask().description("Checkout Default Repository").checkoutItems(new CheckoutItem().defaultRepository()),
new InjectVariablesTask().path("version.properties"),
new VcsBranchTask().branchName("release/\"${APP_VERSION}\"").repository("RED / ui"))
.dockerConfiguration(new DockerConfiguration().image("nexus.iqser.com:5001/infra/release_build:2.9.1")
.volume("/var/run/docker.sock", "/var/run/docker.sock")); .volume("/var/run/docker.sock", "/var/run/docker.sock"));
} }

View File

@ -22,8 +22,10 @@ fi
if [[ -n ${version+z} ]] if [[ -n ${version+z} ]]
then then
echo "Publishing Images with version $version" echo "Publishing Images with version ${version}"
echo "${BAMBOO_DOWNLOAD_PASS} | docker login -u ${BAMBOO_DOWNLOAD_USER} --password-stdin nexus.iqser.com:5001" echo "${BAMBOO_DOWNLOAD_PASS} | docker login -u ${BAMBOO_DOWNLOAD_USER} --password-stdin nexus.iqser.com:5001"
echo "APP_VERSION=${version}" > version.properties;
docker push "${imageName}":latest docker push "${imageName}":latest
docker tag "${imageName}":latest "${imageName}":"${version}" docker tag "${imageName}":latest "${imageName}":"${version}"
docker push "${imageName}":"${version}" docker push "${imageName}":"${version}"