Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JENKINS-51656] - Add support of Configuration-as-Code Plugin to Cust…
…om WAR Packager
- Loading branch information
Showing
with
274 additions
and 30 deletions.
- +6 −3 README.md
- +21 −0 custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/CasCConfig.java
- +24 −0 custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/Config.java
- +11 −3 custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/GroovyHookInfo.java
- +18 −0 custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/WARResourceInfo.java
- +5 −5 custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/BOMBuilder.java
- +23 −8 custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/Builder.java
- +10 −11 custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/JenkinsWarPatcher.java
- +35 −0 demo/casc/Makefile
- +11 −0 demo/casc/README.md
- +70 −0 demo/casc/casc.yml
- +40 −0 demo/casc/packager-config.yml
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,21 @@ | ||
package io.jenkins.tools.warpackager.lib.config; | ||
|
||
/** | ||
* Provides integration with Configuration-as-Code plugin. | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
public class CasCConfig extends WARResourceInfo { | ||
|
||
public static final String CASC_PLUGIN_ARTIFACT_ID = "configuration-as-code"; | ||
|
||
@Override | ||
public String getDestination() { | ||
return "WEB-INF/casc.yml.d"; | ||
} | ||
|
||
@Override | ||
public String getResourceType() { | ||
return "casc.yaml"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,18 @@ | ||
package io.jenkins.tools.warpackager.lib.config; | ||
|
||
/** | ||
* Abstraction for all resources being injected into WARs. | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
public abstract class WARResourceInfo { | ||
public String id; | ||
public SourceInfo source; | ||
|
||
public abstract String getResourceType(); | ||
|
||
/** | ||
* Gets relative path to the resource within WAR. | ||
*/ | ||
public abstract String getDestination(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,35 @@ | ||
# Just a Makefile for manual testing | ||
.PHONY: all | ||
|
||
ARTIFACT_ID = jenkins-casc-demo | ||
VERSION = 256.0-test | ||
|
||
all: clean build | ||
|
||
clean: | ||
rm -rf tmp | ||
|
||
build: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war | ||
|
||
tmp/output/target/${ARTIFACT_ID}-${VERSION}.war: | ||
java \ | ||
-jar $(shell ls ../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar) \ | ||
-configPath packager-config.yml -version ${VERSION} | ||
|
||
run: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war | ||
JENKINS_HOME=work java \ | ||
-Dartifact-manager-s3.enabled=true \ | ||
-jar tmp/output/target/${ARTIFACT_ID}-${VERSION}.war \ | ||
--httpPort=8080 --prefix=/jenkins | ||
|
||
pct: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war | ||
docker run --rm \ | ||
-v ${HOME}/.m2:/root/.m2 \ | ||
-v $(shell pwd)/pct_out:/pct/out \ | ||
-v $(shell pwd)/pct_tmp:/pct/tmp \ | ||
-v $(shell pwd)/tmp/output/target/${ARTIFACT_ID}-${VERSION}.war:/pct/jenkins.war:ro \ | ||
-e ARTIFACT_ID=artifact-manager-s3 \ | ||
-e INSTALL_BUNDLED_SNAPSHOTS=true \ | ||
jenkins/pct \ | ||
-mavenProperties jenkins-test-harness.version=2.38:jth.jenkins-war.path=/pct/jenkins.war | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,11 @@ | ||
Custom WAR Packager. Configuration-as-Code demo | ||
=== | ||
|
||
This demo demonstrates usage of Configuration-as-Code plugin together | ||
with Jenkins Custom WAR Packager. | ||
|
||
Use the provided Makefile in order to build (`make clean build`) | ||
and run (`make run`) the demo. | ||
The root Custom WAR Packager project should be built first before running. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,70 @@ | ||
jenkins: | ||
systemMessage: "Custom War Packager - Demo of Configuration-as-Code plugin" | ||
securityRealm: | ||
local: | ||
allowsSignup: false | ||
users: | ||
- id: "admin" | ||
password: "admin" | ||
- id: "user" | ||
password: "user" | ||
|
||
# Ownership-based Security configuration sample. | ||
# It requires RoleStrategy and Ownership plugins to be installed. | ||
authorizationStrategy: | ||
roleStrategy: | ||
roles: | ||
global: | ||
- name: "admin" | ||
description: "Jenkins administrators" | ||
permissions: | ||
- "Overall/Administer" | ||
assignments: | ||
- "admin" | ||
- name: "readonly" | ||
description: "Read-only users" | ||
permissions: | ||
- "Overall/Read" | ||
- "Job/Read" | ||
- "Agent/Build" | ||
assignments: | ||
- "authenticated" | ||
items: | ||
- name: "@OwnerNoSid" | ||
description: "Primary Owners" | ||
pattern: ".*" | ||
permissions: | ||
- "Job/Configure" | ||
- "Job/Build" | ||
- "Job/Delete" | ||
- "Run/Delete" | ||
assignments: | ||
- "authenticated" | ||
- name: "@CoOwnerNoSid" | ||
description: "Secondary Owners" | ||
pattern: ".*" | ||
permissions: | ||
- "Job/Configure" | ||
- "Job/Build" | ||
assignments: | ||
- "authenticated" | ||
agents: | ||
- name: "@OwnerNoSid" | ||
description: "Primary Owners" | ||
pattern: ".*" | ||
permissions: | ||
- "Agent/Configure" | ||
- "Agent/Build" | ||
- "Agent/Delete" | ||
- "Agent/Build" | ||
assignments: | ||
- "authenticated" | ||
- name: "@CoOwnerNoSid" | ||
description: "Secondary Owners" | ||
pattern: ".*" | ||
permissions: | ||
- "Agent/Connect" | ||
- "Agent/Build" | ||
assignments: | ||
- "authenticated" | ||
|
Oops, something went wrong.