Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from oleg-nenashev/casc-support
[JENKINS-51656] - Add support of Configuration-as-Code Plugin to Custom WAR Packager
- Loading branch information
Showing
12 changed files
with
276 additions
and
30 deletions.
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
21 changes: 21 additions & 0 deletions
21
...om-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/CasCConfig.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/jenkins.yaml.d"; | ||
} | ||
|
||
@Override | ||
public String getResourceType() { | ||
return "jenkins.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
21 changes: 21 additions & 0 deletions
21
...r-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/WARResourceInfo.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.jenkins.tools.warpackager.lib.config; | ||
|
||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
||
/** | ||
* Abstraction for all resources being injected into WARs. | ||
* @author Oleg Nenashev | ||
* @since TODO | ||
*/ | ||
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON Deserialization") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# 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 \ | ||
-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=role-strategy \ | ||
-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.