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
.DS_Store
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.PlanBranchManagement;
import com.atlassian.bamboo.specs.api.builders.project.Project;
import com.atlassian.bamboo.specs.builders.task.CheckoutItem;
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.task.*;
import com.atlassian.bamboo.specs.builders.trigger.BitbucketServerTrigger;
import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties;
import com.atlassian.bamboo.specs.util.BambooServer;
@ -51,10 +47,8 @@ public class PlanSpec {
private PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) {
Permissions permission = new Permissions()
.userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN,
PermissionType.CLONE, PermissionType.BUILD)
.userPermissions("tbejan", PermissionType.ADMIN, PermissionType.EDIT, PermissionType.VIEW,
PermissionType.CLONE, PermissionType.BUILD)
.userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW, PermissionType.ADMIN, 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)
.loggedInUserPermissions(PermissionType.VIEW).anonymousUserPermissionView();
return new PlanPermissions(planIdentifier.getProjectKey(), planIdentifier.getPlanKey()).permissions(permission);
@ -66,38 +60,56 @@ public class PlanSpec {
public Plan createDockerBuildPlan() {
return new Plan(project(), "Redaction UI", new BambooKey("UI"))
.description("Docker build for Redaction UI.").stages(
new Stage("Build Stage").jobs(creatGinCloudPlatformImagesJob("red-ui")))
.stages(new Stage("Upstream Push Stage").jobs(creatGinCloudPlatformUpstreamJob()))
.linkedRepositories("RED / ui").triggers(new BitbucketServerTrigger()).planBranchManagement(
new PlanBranchManagement().createForVcsBranch()
.delete(new BranchCleanup().whenInactiveInRepositoryAfterDays(30)).notificationForCommitters());
.description("Docker build for Redaction UI.")
.stages(new Stage("Build Stage").jobs(creatGinCloudPlatformImagesJob("red-ui")))
.stages(new Stage("Upstream Push Stage")
.jobs(creatGinCloudPlatformUpstreamJob()))
.stages(new Stage("Release")
.manual(true)
.jobs(createRelease()))
.linkedRepositories("RED / ui")
.triggers(new BitbucketServerTrigger()).planBranchManagement(new PlanBranchManagement().createForVcsBranch()
.delete(new BranchCleanup().whenInactiveInRepositoryAfterDays(30)).notificationForCommitters());
}
public Job creatGinCloudPlatformImagesJob(String project) {
return new Job("Build Job: " + project, new BambooKey(project.toUpperCase().replaceAll("-", ""))).tasks(
new VcsCheckoutTask().description("Checkout Default Repository")
.checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask().description("Build")
.location(ScriptTaskProperties.Location.FILE)
.fileFromPath("bamboo-specs/src/main/resources/scripts/build.sh")
.environmentVariables("BAMBOO_DOWNLOAD_PASS=\"${bamboo.bamboo_download_pass}\"")
.environmentVariables("BAMBOO_DOWNLOAD_USER=\"${bamboo.bamboo_download_user}\"")
.environmentVariables("BRANCH_NAME=\"${bamboo.planRepository.branchName}\"")
.environmentVariables("PROJECT=\"" + project + "\"")
).dockerConfiguration(
new DockerConfiguration().image("nexus.iqser.com:5001/infra/release_build:2.9.1")
return new Job("Build Job: " + project, new BambooKey(project.toUpperCase().replaceAll("-", "")))
.tasks(
new VcsCheckoutTask().description("Checkout Default Repository")
.checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask().description("Build")
.location(ScriptTaskProperties.Location.FILE)
.fileFromPath("bamboo-specs/src/main/resources/scripts/build.sh")
.environmentVariables("BAMBOO_DOWNLOAD_PASS=\"${bamboo.bamboo_download_pass}\"")
.environmentVariables("BAMBOO_DOWNLOAD_USER=\"${bamboo.bamboo_download_user}\"")
.environmentVariables("BRANCH_NAME=\"${bamboo.planRepository.branchName}\"")
.environmentVariables("PROJECT=\"" + project + "\"")
).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 creatGinCloudPlatformUpstreamJob() {
return new Job("Upstream Push", new BambooKey("USPSH"))
.tasks(
new VcsCheckoutTask().description("Checkout Default Repository")
.checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask().description("Build")
.location(ScriptTaskProperties.Location.FILE)
.fileFromPath("bamboo-specs/src/main/resources/scripts/update-version.sh")
.environmentVariables("BRANCH_NAME=\"${bamboo.planRepository.branchName}\""),
new VcsCommitTask().commitMessage("chore(release)").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"));
}
public Job creatGinCloudPlatformUpstreamJob() {
return new Job("Upstream Push", new BambooKey("USPSH")).tasks(
new VcsCheckoutTask().description("Checkout Default Repository")
.checkoutItems(new CheckoutItem().defaultRepository()), new ScriptTask().description("Build")
.location(ScriptTaskProperties.Location.FILE)
.fileFromPath("bamboo-specs/src/main/resources/scripts/update-version.sh")
.environmentVariables("BRANCH_NAME=\"${bamboo.planRepository.branchName}\""),
new VcsCommitTask().commitMessage("chore(release)").repository("RED / ui")).dockerConfiguration(
new DockerConfiguration().image("nexus.iqser.com:5001/infra/release_build:2.9.1")
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"));
}

View File

@ -22,8 +22,10 @@ fi
if [[ -n ${version+z} ]]
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 "APP_VERSION=${version}" > version.properties;
docker push "${imageName}":latest
docker tag "${imageName}":latest "${imageName}":"${version}"
docker push "${imageName}":"${version}"