switch back to bamboo Java config
This commit is contained in:
parent
9c4cf3d220
commit
17cbbeb620
@ -1,166 +0,0 @@
|
|||||||
---
|
|
||||||
version: 2
|
|
||||||
|
|
||||||
plan:
|
|
||||||
project-key: RED
|
|
||||||
key: PYINFRA
|
|
||||||
name: pyinfra
|
|
||||||
description: Build for pyinfra
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- Sonar Stage:
|
|
||||||
manual: false
|
|
||||||
final: false
|
|
||||||
jobs:
|
|
||||||
- Sonar Job
|
|
||||||
|
|
||||||
- Git Stage:
|
|
||||||
manual: false
|
|
||||||
final: false
|
|
||||||
jobs:
|
|
||||||
- Git Tag Job
|
|
||||||
|
|
||||||
- Licence Stage:
|
|
||||||
manual: false
|
|
||||||
final: false
|
|
||||||
jobs:
|
|
||||||
- Licence Job
|
|
||||||
|
|
||||||
Sonar Job:
|
|
||||||
key: SONAR
|
|
||||||
docker:
|
|
||||||
image: nexus.iqser.com:5001/infra/release_build:4.2.0
|
|
||||||
volumes:
|
|
||||||
${bamboo.working.directory}: ${bamboo.working.directory}
|
|
||||||
${bamboo.tmp.directory}: ${bamboo.tmp.directory}
|
|
||||||
/var/run/docker.sock: /var/run/docker.sock
|
|
||||||
docker-run-arguments: []
|
|
||||||
tasks:
|
|
||||||
- clean:
|
|
||||||
description: Clean working directory.
|
|
||||||
- checkout:
|
|
||||||
force-clean-build: 'false'
|
|
||||||
description: Checkout default repository.
|
|
||||||
- script:
|
|
||||||
interpreter: SHELL
|
|
||||||
scripts:
|
|
||||||
- |-
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "${bamboo.bamboo_agent_ssh}" | base64 -d >> ~/.ssh/id_rsa
|
|
||||||
echo "host vector.iqser.com" > ~/.ssh/config
|
|
||||||
echo " user bamboo-agent" >> ~/.ssh/config
|
|
||||||
chmod 600 ~/.ssh/config ~/.ssh/id_rsa
|
|
||||||
- script:
|
|
||||||
interpreter: SHELL
|
|
||||||
file: bamboo-specs/scripts/sonar-scan.sh
|
|
||||||
argument: pyinfra
|
|
||||||
description: Run Sonarqube scan.
|
|
||||||
artifact-subscriptions: []
|
|
||||||
|
|
||||||
Git Tag Job:
|
|
||||||
key: GITTAG
|
|
||||||
docker:
|
|
||||||
image: nexus.iqser.com:5001/infra/release_build:4.4.1
|
|
||||||
volumes:
|
|
||||||
${bamboo.working.directory}: ${bamboo.working.directory}
|
|
||||||
${bamboo.tmp.directory}: ${bamboo.tmp.directory}
|
|
||||||
docker-run-arguments: []
|
|
||||||
tasks:
|
|
||||||
- checkout:
|
|
||||||
force-clean-build: 'false'
|
|
||||||
description: Checkout default repository.
|
|
||||||
- script:
|
|
||||||
interpreter: SHELL
|
|
||||||
file: bamboo-specs/scripts/git-tag.sh
|
|
||||||
description: Build git tag.
|
|
||||||
- inject-variables:
|
|
||||||
file: git.tag
|
|
||||||
scope: LOCAL
|
|
||||||
namespace: g
|
|
||||||
description: Inject git tag.
|
|
||||||
- any-task:
|
|
||||||
plugin-key: com.atlassian.bamboo.plugins.vcs:task.vcs.tagging
|
|
||||||
configuration:
|
|
||||||
selectedRepository: defaultRepository
|
|
||||||
tagName: ${bamboo.g.gitTag}
|
|
||||||
description: ${bamboo.g.gitTag}
|
|
||||||
artifact-subscriptions: []
|
|
||||||
|
|
||||||
Licence Job:
|
|
||||||
key: LICENCE
|
|
||||||
docker:
|
|
||||||
image: nexus.iqser.com:5001/infra/maven:3.6.2-jdk-13-3.0.0
|
|
||||||
volumes:
|
|
||||||
${bamboo.working.directory}: ${bamboo.working.directory}
|
|
||||||
${bamboo.tmp.directory}: ${bamboo.tmp.directory}
|
|
||||||
/etc/maven/settings.xml: /usr/share/maven/ref/settings.xml
|
|
||||||
/var/run/docker.sock: /var/run/docker.sock
|
|
||||||
docker-run-arguments: []
|
|
||||||
tasks:
|
|
||||||
- checkout:
|
|
||||||
force-clean-build: 'false'
|
|
||||||
description: Checkout default repository.
|
|
||||||
- script:
|
|
||||||
interpreter: SHELL
|
|
||||||
file: bamboo-specs/scripts/create-licence.sh
|
|
||||||
description: Build licence.
|
|
||||||
artifact-subscriptions: []
|
|
||||||
|
|
||||||
repositories:
|
|
||||||
- RR / pyinfra:
|
|
||||||
scope: global
|
|
||||||
|
|
||||||
triggers:
|
|
||||||
- bitbucket-server-trigger
|
|
||||||
|
|
||||||
branches:
|
|
||||||
create: for-new-branch
|
|
||||||
delete:
|
|
||||||
after-deleted-days: never
|
|
||||||
after-inactive-days: 14
|
|
||||||
link-to-jira: true
|
|
||||||
|
|
||||||
notifications: []
|
|
||||||
|
|
||||||
labels: []
|
|
||||||
|
|
||||||
dependencies:
|
|
||||||
require-all-stages-passing: true
|
|
||||||
enabled-for-branches: true
|
|
||||||
block-strategy: none
|
|
||||||
plans: []
|
|
||||||
|
|
||||||
other:
|
|
||||||
concurrent-build-plugin: system-default
|
|
||||||
---
|
|
||||||
version: 2
|
|
||||||
|
|
||||||
plan:
|
|
||||||
key: RED-PYINFRA
|
|
||||||
|
|
||||||
plan-permissions:
|
|
||||||
- roles:
|
|
||||||
- logged-in
|
|
||||||
- anonymous
|
|
||||||
permissions:
|
|
||||||
- view
|
|
||||||
- users:
|
|
||||||
- atlbamboo
|
|
||||||
permissions:
|
|
||||||
- view
|
|
||||||
- edit
|
|
||||||
- build
|
|
||||||
- clone
|
|
||||||
- admin
|
|
||||||
- view-configuration
|
|
||||||
- groups:
|
|
||||||
- QA
|
|
||||||
- research
|
|
||||||
- Development
|
|
||||||
permissions:
|
|
||||||
- view
|
|
||||||
- edit
|
|
||||||
- build
|
|
||||||
- clone
|
|
||||||
- view-configuration
|
|
||||||
...
|
|
||||||
40
bamboo-specs/pom.xml
Normal file
40
bamboo-specs/pom.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.atlassian.bamboo</groupId>
|
||||||
|
<artifactId>bamboo-specs-parent</artifactId>
|
||||||
|
<version>7.1.2</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>bamboo-specs</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<sonar.skip>true</sonar.skip>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atlassian.bamboo</groupId>
|
||||||
|
<artifactId>bamboo-specs-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atlassian.bamboo</groupId>
|
||||||
|
<artifactId>bamboo-specs</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<!-- run 'mvn test' to perform offline validation of the plan -->
|
||||||
|
<!-- run 'mvn -Ppublish-specs' to upload the plan to your Bamboo server -->
|
||||||
|
</project>
|
||||||
163
bamboo-specs/src/main/java/buildjob/PlanSpec.java
Normal file
163
bamboo-specs/src/main/java/buildjob/PlanSpec.java
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
package buildjob;
|
||||||
|
|
||||||
|
import com.atlassian.bamboo.specs.api.BambooSpec;
|
||||||
|
import com.atlassian.bamboo.specs.api.builders.BambooKey;
|
||||||
|
import com.atlassian.bamboo.specs.api.builders.docker.DockerConfiguration;
|
||||||
|
import com.atlassian.bamboo.specs.api.builders.permission.PermissionType;
|
||||||
|
import com.atlassian.bamboo.specs.api.builders.permission.Permissions;
|
||||||
|
import com.atlassian.bamboo.specs.api.builders.permission.PlanPermissions;
|
||||||
|
import com.atlassian.bamboo.specs.api.builders.plan.Job;
|
||||||
|
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.plan.Stage;
|
||||||
|
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.InjectVariablesTask;
|
||||||
|
import com.atlassian.bamboo.specs.builders.task.ScriptTask;
|
||||||
|
import com.atlassian.bamboo.specs.builders.task.VcsCheckoutTask;
|
||||||
|
import com.atlassian.bamboo.specs.builders.task.CleanWorkingDirectoryTask;
|
||||||
|
import com.atlassian.bamboo.specs.builders.task.VcsTagTask;
|
||||||
|
import com.atlassian.bamboo.specs.builders.trigger.BitbucketServerTrigger;
|
||||||
|
import com.atlassian.bamboo.specs.model.task.InjectVariablesScope;
|
||||||
|
import com.atlassian.bamboo.specs.util.BambooServer;
|
||||||
|
import com.atlassian.bamboo.specs.model.task.ScriptTaskProperties.Location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
||||||
|
|
||||||
|
private static final String SERVICE_NAME = "pyinfra";
|
||||||
|
|
||||||
|
private static final String SERVICE_KEY = SERVICE_NAME.toUpperCase().replaceAll("-", "");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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().createBuildPlan();
|
||||||
|
bambooServer.publish(plan);
|
||||||
|
PlanPermissions planPermission = new PlanSpec().createPlanPermission(plan.getIdentifier());
|
||||||
|
bambooServer.publish(planPermission);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PlanPermissions createPlanPermission(PlanIdentifier planIdentifier) {
|
||||||
|
Permissions permission = new Permissions()
|
||||||
|
.userPermissions("atlbamboo", PermissionType.EDIT, PermissionType.VIEW, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Project project() {
|
||||||
|
return new Project()
|
||||||
|
.name("RED")
|
||||||
|
.key(new BambooKey("RED"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plan createBuildPlan() {
|
||||||
|
return new Plan(
|
||||||
|
project(),
|
||||||
|
SERVICE_NAME, new BambooKey(SERVICE_KEY))
|
||||||
|
.description("Build for pyinfra")
|
||||||
|
.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.")
|
||||||
|
.inlineBody("mkdir -p ~/.ssh\n" +
|
||||||
|
"echo \"${bamboo.bamboo_agent_ssh}\" | base64 -d >> ~/.ssh/id_rsa\n"
|
||||||
|
+
|
||||||
|
"echo \"host vector.iqser.com\" > ~/.ssh/config\n"
|
||||||
|
+
|
||||||
|
"echo \" user bamboo-agent\" >> ~/.ssh/config\n"
|
||||||
|
+
|
||||||
|
"chmod 600 ~/.ssh/config ~/.ssh/id_rsa"),
|
||||||
|
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("Git Stage")
|
||||||
|
.jobs(
|
||||||
|
new Job("Git Tag Job", new BambooKey("GITTAG"))
|
||||||
|
.tasks(
|
||||||
|
new VcsCheckoutTask()
|
||||||
|
.description("Checkout default repository.")
|
||||||
|
.checkoutItems(new CheckoutItem().defaultRepository()),
|
||||||
|
new ScriptTask()
|
||||||
|
.description("Build git tag.")
|
||||||
|
.location(Location.FILE)
|
||||||
|
.fileFromPath(
|
||||||
|
"bamboo-specs/src/main/resources/scripts/git-tag.sh"),
|
||||||
|
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.4.1"))),
|
||||||
|
new Stage("Licence Stage")
|
||||||
|
.jobs(
|
||||||
|
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)
|
||||||
|
.triggers(new BitbucketServerTrigger())
|
||||||
|
.planBranchManagement(
|
||||||
|
new PlanBranchManagement()
|
||||||
|
.createForVcsBranch()
|
||||||
|
.delete(new BranchCleanup()
|
||||||
|
.whenInactiveInRepositoryAfterDays(14))
|
||||||
|
.notificationForCommitters());
|
||||||
|
}
|
||||||
|
}
|
||||||
16
bamboo-specs/src/test/java/buildjob/PlanSpecTest.java
Normal file
16
bamboo-specs/src/test/java/buildjob/PlanSpecTest.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package buildjob;
|
||||||
|
|
||||||
|
|
||||||
|
import com.atlassian.bamboo.specs.api.builders.plan.Plan;
|
||||||
|
import com.atlassian.bamboo.specs.api.exceptions.PropertiesValidationException;
|
||||||
|
import com.atlassian.bamboo.specs.api.util.EntityPropertiesBuilders;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class PlanSpecTest {
|
||||||
|
@Test
|
||||||
|
public void checkYourPlanOffline() throws PropertiesValidationException {
|
||||||
|
Plan plan = new PlanSpec().createDockerBuildPlan();
|
||||||
|
|
||||||
|
EntityPropertiesBuilders.build(plan);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user