Update 8 files
- /bamboo-specs/src/main/java/buildjob/PlanSpec.java - /bamboo-specs/src/main/resources/scripts/build.sh - /bamboo-specs/src/test/java/buildjob/PlanSpecTest.java - /bamboo-specs/.gitignore - /bamboo-specs/pom.xml - /versions.sh - /docker/.gitlab-ci.yml - /.gitmodules
This commit is contained in:
parent
679b240889
commit
f4a147536c
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +1,4 @@
|
||||
[submodule "libs/common-ui"]
|
||||
path = libs/common-ui
|
||||
url = ssh://git@git.iqser.com:2222/sl/common-ui.git
|
||||
url = ../../fforesight/shared-ui-libraries/common-ui.git
|
||||
# url = ssh://git@git.iqser.com:2222/sl/common-ui.git
|
||||
|
||||
1
bamboo-specs/.gitignore
vendored
1
bamboo-specs/.gitignore
vendored
@ -1 +0,0 @@
|
||||
target/
|
||||
@ -1,36 +0,0 @@
|
||||
<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>8.1.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<artifactId>bamboo-specs</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<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>
|
||||
@ -1,127 +0,0 @@
|
||||
package buildjob;
|
||||
|
||||
import com.atlassian.bamboo.specs.api.BambooSpec;
|
||||
import com.atlassian.bamboo.specs.api.builders.BambooKey;
|
||||
import com.atlassian.bamboo.specs.api.builders.credentials.SharedCredentialsIdentifier;
|
||||
import com.atlassian.bamboo.specs.api.builders.credentials.SharedCredentialsScope;
|
||||
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.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.api.builders.repository.VcsRepositoryIdentifier;
|
||||
import com.atlassian.bamboo.specs.builders.repository.git.GitRepository;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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 buildPlan = new PlanSpec().createDockerBuildPlan();
|
||||
bambooServer.publish(buildPlan);
|
||||
PlanPermissions buildPlanPermissions = new PlanSpec().createPlanPermission(buildPlan.getIdentifier());
|
||||
bambooServer.publish(buildPlanPermissions);
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
.groupPermissions("devplant", PermissionType.EDIT, PermissionType.VIEW, PermissionType.BUILD)
|
||||
.groupPermissions("Documentation", PermissionType.VIEW)
|
||||
.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(), "Redaction UI", new BambooKey("UI"))
|
||||
.description("Docker build for Redaction UI.")
|
||||
.stages(new Stage("UI Build Stage")
|
||||
.jobs(creatGinCloudPlatformImagesJob("red-ui")))
|
||||
.stages(new Stage("Release")
|
||||
.manual(true)
|
||||
.jobs(createRelease()))
|
||||
.linkedRepositories("RED / ui")
|
||||
.linkedRepositories("Shared Libraries / common-ui")
|
||||
.triggers(new BitbucketServerTrigger().selectedTriggeringRepositories(new VcsRepositoryIdentifier("RED / ui")))
|
||||
.planBranchManagement(new PlanBranchManagement().createForVcsBranch().delete(new BranchCleanup().whenInactiveInRepositoryAfterDays(30)).notificationForCommitters());
|
||||
}
|
||||
|
||||
public Job creatGinCloudPlatformImagesJob(String project) {
|
||||
return new Job("Build Job UI" , new BambooKey("UIBUILD"))
|
||||
.tasks(
|
||||
new CleanWorkingDirectoryTask().description("My clean working directory task"),
|
||||
// Checkout
|
||||
new VcsCheckoutTask().description("Checkout Default Repository")
|
||||
.checkoutItems(new CheckoutItem().defaultRepository().path("redaction-ui")),
|
||||
|
||||
// Build
|
||||
new ScriptTask().description("Build")
|
||||
.location(ScriptTaskProperties.Location.FILE)
|
||||
.workingSubdirectory("redaction-ui")
|
||||
.fileFromPath("bamboo-specs/src/main/resources/scripts/build.sh")
|
||||
.environmentVariables(
|
||||
"PROJECT=\"" + project + "\" " +
|
||||
"BAMBOO_DOWNLOAD_PASS=\"${bamboo.bamboo_download_pass}\" " +
|
||||
"BAMBOO_DOWNLOAD_USER=\"${bamboo.bamboo_download_user}\" "),
|
||||
// read version from artifact
|
||||
new InjectVariablesTask().path("redaction-ui/version.properties"),
|
||||
// commit release
|
||||
new VcsCommitTask().commitMessage("chore(release)").repository("RED / ui"),
|
||||
// create tag with this version
|
||||
new VcsTagTask().tagName("${bamboo.inject.APP_VERSION}").repository("RED / ui")
|
||||
).dockerConfiguration(
|
||||
new DockerConfiguration().image("nexus.knecon.com:5001/infra/release_build:4.2.0")
|
||||
.volume("/var/run/docker.sock", "/var/run/docker.sock"))
|
||||
.artifacts(new Artifact("version").location(".").copyPattern("**/version.properties").shared(true),
|
||||
new Artifact("paligo-theme.tar.gz").location(".").copyPattern("**/paligo-theme.tar.gz").shared(true));
|
||||
}
|
||||
|
||||
|
||||
public Job createRelease() {
|
||||
return new Job("Create Release", new BambooKey("CRLS"))
|
||||
.tasks(
|
||||
new CleanWorkingDirectoryTask().description("My clean working directory task"),
|
||||
new VcsCheckoutTask().description("Checkout Default Repository")
|
||||
.checkoutItems(new CheckoutItem().defaultRepository()).cleanCheckout(true),
|
||||
|
||||
new ArtifactDownloaderTask().description("Download version artifact")
|
||||
.sourcePlan(new PlanIdentifier("RED", "UI"))
|
||||
.artifacts(new DownloadItem().artifact("version")),
|
||||
// read version from artifact
|
||||
new InjectVariablesTask().path("redaction-ui/version.properties"),
|
||||
|
||||
new ScriptTask().description("checkout tag").inlineBody("git checkout tags/${bamboo.inject.APP_VERSION}"),
|
||||
|
||||
|
||||
new VcsBranchTask().branchName("release/${bamboo.inject.APP_VERSION}").repository("RED / ui"))
|
||||
.dockerConfiguration(new DockerConfiguration().image("nexus.knecon.com:5001/infra/release_build:2.9.1")
|
||||
.volume("/var/run/docker.sock", "/var/run/docker.sock"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
|
||||
imageName="nexus.knecon.com:5001/red/$PROJECT"
|
||||
dockerfileLocation="docker/$PROJECT/Dockerfile"
|
||||
|
||||
echo "submodule status"
|
||||
git submodule status
|
||||
|
||||
echo "On branch $bamboo_planRepository_branchName building project $PROJECT"
|
||||
# shellcheck disable=SC2154
|
||||
if [[ "$bamboo_planRepository_branchName" == "master" ]]
|
||||
then
|
||||
./versions.sh minor
|
||||
version=$(jq -r '.version' < package.json)
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$bamboo_planRepository_branchName" == release* ]]
|
||||
then
|
||||
./versions.sh patch
|
||||
version=$(jq -r '.version' < package.json)
|
||||
fi
|
||||
|
||||
|
||||
echo "Building version $version"
|
||||
docker build --build-arg bamboo_sonarqube_api_token_secret=${bamboo_sonarqube_api_token_secret} -t "$imageName":latest -f "$dockerfileLocation" .
|
||||
|
||||
if [[ -n ${version+z} ]]
|
||||
then
|
||||
|
||||
echo "APP_VERSION=${version}" > version.properties
|
||||
|
||||
echo "Publishing Images with version $version"
|
||||
echo "$BAMBOO_DOWNLOAD_PASS" | docker login -u "$BAMBOO_DOWNLOAD_USER" --password-stdin nexus.knecon.com:5001
|
||||
|
||||
# re-build intermediate build stage from layer cache, run image and get artifacts ( paligo theme )
|
||||
docker build --build-arg bamboo_sonarqube_api_token_secret=${bamboo_sonarqube_api_token_secret} --target builder -t builder-image:latest -f "$dockerfileLocation" .
|
||||
mkdir -p ./paligo-theme
|
||||
docker run -v "$(pwd)"/paligo-theme:/tmp/styles-export builder-image:latest
|
||||
tar -czvf paligo-theme.tar.gz ./paligo-theme
|
||||
|
||||
docker push "$imageName:latest"
|
||||
docker tag "$imageName:latest" "$imageName:$version"
|
||||
docker push "$imageName:$version"
|
||||
|
||||
else
|
||||
echo "Not on a relevant branch $bamboo_planRepository_branchName ... skipping."
|
||||
echo "APP_VERSION=BRANCH-$bamboo_planRepository_branchName-$bamboo_buildNumber" > version.properties
|
||||
|
||||
if [[ ! -z "$bamboo_version_tag" ]]
|
||||
then
|
||||
echo "$BAMBOO_DOWNLOAD_PASS" | docker login -u "$BAMBOO_DOWNLOAD_USER" --password-stdin nexus.knecon.com:5001
|
||||
echo "Pushing custom tag: $bamboo_version_tag"
|
||||
docker tag "$imageName:latest" "$imageName:$bamboo_version_tag"
|
||||
docker push "$imageName:$bamboo_version_tag"
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
@ -1,16 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
10
docker/.gitlab-ci.yml
Normal file
10
docker/.gitlab-ci.yml
Normal file
@ -0,0 +1,10 @@
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
GIT_SUBMODULE_FORCE_HTTPS: "true"
|
||||
PROJECT: red-ui
|
||||
DOCKERFILELOCATION: "docker/$PROJECT/Dockerfile"
|
||||
|
||||
include:
|
||||
- project: 'gitlab/gitlab'
|
||||
ref: 'main'
|
||||
file: 'ci-templates/docker_build_nexus.yml'
|
||||
47
versions.sh
47
versions.sh
@ -1,47 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function bump() {
|
||||
|
||||
if [ "$1" == "major" ] || [ "$1" == "minor" ] || [ "$1" == "patch" ]; then
|
||||
current_version=$(cat package.json | jq -r '.version')
|
||||
|
||||
IFS='.' read -a version_parts <<< "$current_version"
|
||||
|
||||
major=${version_parts[0]}
|
||||
minor=${version_parts[1]}
|
||||
patch=${version_parts[2]}
|
||||
|
||||
case "$1" in
|
||||
"major")
|
||||
major=$((major + 1))
|
||||
minor=0
|
||||
patch=0
|
||||
;;
|
||||
"minor")
|
||||
minor=$((minor + 1))
|
||||
patch=0
|
||||
;;
|
||||
"patch")
|
||||
patch=$((patch + 1))
|
||||
;;
|
||||
esac
|
||||
new_version="$major.$minor.$patch"
|
||||
echo "New Version is $new_version"
|
||||
|
||||
cat package.json | jq ".version = \"$new_version\"" > temp.json
|
||||
mv temp.json package.json
|
||||
|
||||
cat package-lock.json | jq ".version = \"$new_version\"" > temp.json
|
||||
mv temp.json package-lock.json
|
||||
|
||||
else
|
||||
echo >&2 "No patch type set. Aborting."
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
echo "Bumping version ... "
|
||||
bump $1
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user