├── .dockerignore
├── .github
├── CODEOWNERS
├── dependabot.yml
├── release-drafter.yml
└── workflows
│ └── release-drafter.yml
├── .gitignore
├── CHANGELOG.md
├── Dockerfile
├── Jenkinsfile
├── LICENSE.md
├── README.md
├── ROADMAP.adoc
├── custom-war-packager-cli
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── io
│ │ │ └── jenkins
│ │ │ └── tools
│ │ │ └── warpackager
│ │ │ └── cli
│ │ │ ├── CliOptions.java
│ │ │ └── Main.java
│ └── resources
│ │ └── io
│ │ └── jenkins
│ │ └── tools
│ │ └── warpackager
│ │ └── cli
│ │ └── config
│ │ └── sample.yml
│ └── test
│ └── java
│ └── io
│ └── jenkins
│ └── tools
│ └── warpackager
│ └── cli
│ └── MainTest.java
├── custom-war-packager-lib
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── io
│ │ │ └── jenkins
│ │ │ └── tools
│ │ │ └── warpackager
│ │ │ └── lib
│ │ │ ├── config
│ │ │ ├── BuildSettings.java
│ │ │ ├── CasCConfig.java
│ │ │ ├── Config.java
│ │ │ ├── DependencyBuildSettings.java
│ │ │ ├── DependencyInfo.java
│ │ │ ├── DockerBuildSettings.java
│ │ │ ├── EssentialsYMLConfig.java
│ │ │ ├── GroovyHookInfo.java
│ │ │ ├── JenkinsRepositorySettings.java
│ │ │ ├── JenkinsfileRunnerSettings.java
│ │ │ ├── LibraryInfo.java
│ │ │ ├── PackageInfo.java
│ │ │ ├── SourceInfo.java
│ │ │ ├── WARResourceInfo.java
│ │ │ └── WarInfo.java
│ │ │ ├── impl
│ │ │ ├── BOMBuilder.java
│ │ │ ├── Builder.java
│ │ │ ├── JenkinsDockerfileBuilder.java
│ │ │ ├── JenkinsWarPatcher.java
│ │ │ ├── MavenHPICustomWARPOMGenerator.java
│ │ │ ├── MavenWARPackagePOMGenerator.java
│ │ │ ├── POMGenerator.java
│ │ │ ├── PackagerBase.java
│ │ │ ├── jenkinsfileRunner
│ │ │ │ └── JenkinsfileRunnerDockerBuilder.java
│ │ │ └── plugins
│ │ │ │ ├── MavenPluginInfoProvider.java
│ │ │ │ └── UpdateCenterPluginInfoProvider.java
│ │ │ ├── model
│ │ │ ├── bom
│ │ │ │ ├── BOM.java
│ │ │ │ ├── ComponentReference.java
│ │ │ │ ├── Environment.java
│ │ │ │ ├── Metadata.java
│ │ │ │ ├── Reference.java
│ │ │ │ └── Specification.java
│ │ │ └── plugins
│ │ │ │ └── PluginInfoProvider.java
│ │ │ └── util
│ │ │ ├── CollectionsHelper.java
│ │ │ ├── DockerfileBuilder.java
│ │ │ ├── MavenHelper.java
│ │ │ ├── SimpleManifest.java
│ │ │ └── SystemCommandHelper.java
│ └── resources
│ │ └── io
│ │ └── jenkins
│ │ └── tools
│ │ └── warpackager
│ │ └── lib
│ │ └── config
│ │ └── sample.yml
│ └── test
│ ├── java
│ └── io
│ │ └── jenkins
│ │ └── tools
│ │ └── warpackager
│ │ └── lib
│ │ ├── config
│ │ └── ConfigTest.java
│ │ └── model
│ │ └── bom
│ │ └── BOMTest.java
│ └── resources
│ └── io
│ └── jenkins
│ └── tools
│ └── warpackager
│ └── lib
│ └── model
│ └── bom
│ └── BOM.yml
├── custom-war-packager-maven-plugin
├── pom.xml
└── src
│ ├── it
│ ├── bom
│ │ ├── bom.yml
│ │ ├── config.yml
│ │ ├── invoker.properties
│ │ └── pom.xml
│ ├── casc
│ │ ├── bom.yml
│ │ ├── casc.yml
│ │ ├── config.yml
│ │ ├── invoker.properties
│ │ └── pom.xml
│ ├── custom-uc
│ │ ├── casc.yml
│ │ ├── config.yml
│ │ ├── invoker.properties
│ │ └── pom.xml
│ ├── incrementals
│ │ ├── config.yml
│ │ ├── invoker.properties
│ │ └── pom.xml
│ ├── pom-with-maven-info-source
│ │ ├── Makefile
│ │ ├── casc.yml
│ │ ├── config.yml
│ │ ├── invoker.properties
│ │ └── pom.xml
│ ├── pom
│ │ ├── Makefile
│ │ ├── casc.yml
│ │ ├── config.yml
│ │ ├── invoker.properties
│ │ └── pom.xml
│ └── spotcheck
│ │ ├── invoker.properties
│ │ ├── pom.xml
│ │ └── spotcheck.yml
│ └── main
│ └── java
│ └── io
│ └── jenkins
│ └── tools
│ └── warpackager
│ └── mavenplugin
│ ├── BuildMojo.java
│ └── PackageMojo.java
├── demo
├── all-latest-core-maven
│ ├── README.md
│ ├── pom.xml
│ └── run.sh
├── all-latest-core
│ ├── README.md
│ ├── build.sh
│ ├── packager-config.yml
│ └── run.sh
├── artifact-manager-s3-pom
│ ├── Makefile
│ ├── README.md
│ ├── packager-config.yml
│ └── pom.xml
├── casc
│ ├── Makefile
│ ├── README.md
│ ├── casc.yml
│ └── packager-config.yml
├── external-logging-elasticsearch
│ ├── Makefile
│ ├── README.md
│ ├── docker-compose.yml
│ ├── packager-config.yml
│ └── src
│ │ └── main
│ │ └── groovy
│ │ ├── 1_System.groovy
│ │ ├── 2_Logstash.groovy
│ │ ├── 3_Agent.groovy
│ │ ├── 4_Jobs.groovy
│ │ └── 5_SaveToDisk.groovy
├── jenkinsfile-runner
│ ├── Makefile
│ ├── README.md
│ ├── casc.yml
│ ├── demo
│ │ ├── Jenkinsfile
│ │ └── kubernetes.yaml
│ ├── init.groovy
│ └── packager-config.yml
├── multi-platform-images
│ ├── README.md
│ ├── build.sh
│ └── packager-config.yml
└── stapler
│ ├── README.md
│ ├── build.sh
│ └── packager-config.yml
├── jenkinsfile-runner-tests
├── Makefile
├── README.md
├── exclude-rsync.txt
├── pom.xml
├── test_resources
│ ├── test_cwp_casc_simple
│ │ ├── Jenkinsfile
│ │ ├── casc.yml
│ │ └── packager-config.yml
│ ├── test_cwp_casc_with_pipeline_library
│ │ ├── Jenkinsfile
│ │ ├── casc.yml
│ │ └── packager-config.yml
│ ├── test_cwp_casc_with_tool
│ │ ├── Jenkinsfile
│ │ ├── casc.yml
│ │ └── packager-config.yml
│ ├── test_cwp_classloading
│ │ ├── Jenkinsfile
│ │ └── packager-config.yml
│ ├── test_cwp_commit
│ │ ├── Jenkinsfile
│ │ └── packager-config.yml
│ ├── test_cwp_jfr
│ │ ├── Jenkinsfile
│ │ └── packager-config.yml
│ ├── test_cwp_sandbox_configuration
│ │ ├── Jenkinsfile
│ │ └── packager-config.yml
│ ├── test_cwp_with_groovy_hooks
│ │ ├── Jenkinsfile
│ │ ├── init.groovy
│ │ └── packager-config.yml
│ ├── test_cwp_workspace
│ │ ├── Jenkinsfile
│ │ └── packager-config.yml
│ ├── test_cwp_workspace_non_default
│ │ ├── Jenkinsfile
│ │ └── packager-config.yml
│ ├── test_war_from_pom
│ │ ├── packager-config-with-dependency.yml
│ │ ├── packager-config-with-property.yml
│ │ ├── packager-config-with-war-property.yml
│ │ ├── packager-config.yml
│ │ ├── pom-with-dependency.xml
│ │ ├── pom-with-property.xml
│ │ ├── pom-with-war-property.xml
│ │ └── pom.xml
│ └── test_war_not_from_pom
│ │ ├── packager-config-with-dependency.yml
│ │ ├── packager-config-with-property.yml
│ │ ├── packager-config-with-war-property.yml
│ │ ├── packager-config.yml
│ │ ├── pom-with-dependency.xml
│ │ ├── pom-with-property.xml
│ │ ├── pom-with-war-property.xml
│ │ └── pom.xml
└── tests.sh
├── packaging
└── docker-builder
│ ├── Dockerfile
│ └── README.md
└── pom.xml
/.dockerignore:
--------------------------------------------------------------------------------
1 | /demo
2 | /test
3 | /jenkinsfile-runner-tests
4 | target
5 | tmp
6 | *.log
7 |
8 | # IDEA
9 | *.iml
10 | .idea
11 |
12 | # VS Code
13 | .project
14 | .settings
15 | .classpath
16 | .factorypath
17 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @oleg-nenashev
2 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "maven"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | # https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc
2 | _extends: .github
3 | version-template: $MAJOR.$MINOR-alpha-$PATCH
4 | tag-template: v$NEXT_PATCH_VERSION
5 |
--------------------------------------------------------------------------------
/.github/workflows/release-drafter.yml:
--------------------------------------------------------------------------------
1 | # Note: additional setup is required, see https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc
2 |
3 | name: Release Drafter
4 |
5 | on:
6 | push:
7 | branches:
8 | - master
9 |
10 | jobs:
11 | update_release_draft:
12 | runs-on: ubuntu-latest
13 | steps:
14 | # Drafts your next Release notes as Pull Requests are merged into the default branch
15 | - uses: release-drafter/release-drafter@v5
16 | env:
17 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /test
2 | target
3 | demo/**/.build
4 | tmp
5 |
6 | *.log
7 | jenkinsfile-runner-tests/.testing
8 | jenkinsfile-runner-tests/.jenkinsfile-runner-test-framework/
9 | jenkinsfile-runner-tests/cwp.jar
10 |
11 | # IDEA
12 | *.iml
13 | .idea
14 |
15 | # VS Code
16 | .project
17 | .settings
18 | .classpath
19 | .factorypath
20 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM maven:alpine as maven
2 | WORKDIR /app
3 | COPY ./ ./
4 | RUN mvn package -DskipTests
5 |
6 | FROM maven:alpine
7 | ENV VERSION=1.3-SNAPSHOT
8 | RUN apk --no-cache add git
9 | WORKDIR /app
10 | COPY --from=maven /app/custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar /app/custom-war-packager-cli.jar
11 | ENTRYPOINT ["java", "-jar", "/app/custom-war-packager-cli.jar"]
12 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | /* Only keep the 10 most recent builds. */
2 | properties([[$class: 'BuildDiscarderProperty',
3 | strategy: [$class: 'LogRotator', numToKeepStr: '10']]])
4 |
5 | // TODO: Move it to Jenkins Pipeline Library
6 |
7 | /* These platforms correspond to labels in ci.jenkins.io, see:
8 | * https://github.com/jenkins-infra/documentation/blob/master/ci.adoc
9 | */
10 | List platforms = ['linux']
11 | Map branches = [:]
12 |
13 | for (int i = 0; i < platforms.size(); ++i) {
14 | String label = platforms[i]
15 | branches[label] = {
16 | node(label) {
17 | timestamps {
18 | stage('Checkout') {
19 | checkout scm
20 | }
21 |
22 | stage('Build') {
23 | withEnv([
24 | "JAVA_HOME=${tool 'jdk8'}",
25 | "PATH+MVN=${tool 'mvn'}/bin",
26 | 'PATH+JDK=$JAVA_HOME/bin',
27 | ]) {
28 | timeout(60) {
29 | String command = 'mvn --batch-mode clean install -Dmaven.test.failure.ignore=true -Denvironment=test -Prun-its'
30 | if (isUnix()) {
31 | sh command
32 | }
33 | else {
34 | bat command
35 | }
36 | }
37 | }
38 | }
39 |
40 | stage('Archive') {
41 | /* Archive the test results */
42 | junit '**/target/surefire-reports/TEST-*.xml'
43 |
44 | if (label == 'linux') {
45 | archiveArtifacts artifacts: '**/target/**/*.jar'
46 | recordIssues(
47 | enabledForFailure: true, aggregatingResults: true,
48 | tools: [java(), spotBugs(pattern: '**/target/spotbugsXml.xml')]
49 | )
50 | }
51 | }
52 | }
53 | }
54 | }
55 | }
56 |
57 | /* Execute our platforms in parallel */
58 | parallel(branches)
59 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018-2019 CloudBees Inc., Oleg Nenashev, and other Jenkins contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/custom-war-packager-cli/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | io.jenkins.tools.custom-war-packager
7 | parent-pom
8 | 2.0-alpha-7-SNAPSHOT
9 |
10 |
11 | custom-war-packager-cli
12 | jar
13 | 2.0-alpha-7-SNAPSHOT
14 |
15 | Jenkins Custom WAR Packager CLI
16 | Generates a Custom WAR file from the specified YAML configuration file
17 |
18 |
19 |
20 | args4j
21 | args4j
22 | 2.33
23 |
24 |
25 |
26 | io.jenkins.tools.custom-war-packager
27 | custom-war-packager-lib
28 | ${project.version}
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | maven-assembly-plugin
37 |
38 |
39 |
40 |
41 | single
42 |
43 | package
44 |
45 |
46 | jar-with-dependencies
47 |
48 |
49 |
50 | io.jenkins.tools.warpackager.cli.Main
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/custom-war-packager-cli/src/main/java/io/jenkins/tools/warpackager/cli/CliOptions.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.cli;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.BuildSettings;
4 | import org.kohsuke.args4j.Option;
5 |
6 | import javax.annotation.CheckForNull;
7 | import javax.annotation.Nonnull;
8 | import java.io.File;
9 |
10 | public class CliOptions {
11 |
12 | @Option(name = "-configPath", usage = "Path to the configuration YAML. See the tool's README for format")
13 | public File configPath;
14 |
15 | @Option(name = "-mvnSettingsFile", usage = "Path to a custom Maven settings file to be used within the build")
16 | public File mvnSettingsFile;
17 |
18 | @Option(name = "-tmpDir", usage = "Temporary directory for generated files and the output WAR. Defaults to '" + BuildSettings.DEFAULT_TMP_DIR_NAME + "'")
19 | public File tmpDir;
20 |
21 | @Option(name = "-version", usage = "Version of WAR to be set. Defaults to '" + BuildSettings.DEFAULT_VERSION + "'")
22 | public String version;
23 |
24 | @Option(name = "-demo", usage = "Enables demo mode with predefined config file")
25 | public boolean demo;
26 |
27 | @Option(name = "--batch-mode", usage = "Enables the batch mode for the build")
28 | public boolean batchMode;
29 |
30 | @Option(name = "--bomPath", usage = "Path to the BOM file. If defined, it will override settings in Config YAML")
31 | public File bomPath;
32 |
33 | @Option(name = "--environment", usage = "Environment to be used")
34 | public String environment;
35 |
36 | @Option(name = "--installArtifacts", usage = "If set, the final artifacts will be automatically installed to the local repository (current version - only WAR)")
37 | public boolean installArtifacts;
38 |
39 | @Option(name = "--updateCenterUrl", usage = "URL of the update center. If defined, it will override settings in Config YAML")
40 | public String updateCenterUrl;
41 |
42 | @CheckForNull
43 | public File getConfigPath() {
44 | return configPath;
45 | }
46 |
47 | @Nonnull
48 | public File getTmpDir() {
49 | return tmpDir != null ? tmpDir : BuildSettings.DEFAULT_TMP_DIR;
50 | }
51 |
52 | @Nonnull
53 | public String getVersion() {
54 | return version != null ? version : BuildSettings.DEFAULT_VERSION;
55 | }
56 |
57 | @CheckForNull
58 | public File getMvnSettingsFile() {
59 | return mvnSettingsFile;
60 | }
61 |
62 | @CheckForNull
63 | public File getBOMPath() {
64 | return bomPath;
65 | }
66 |
67 | @CheckForNull
68 | public String getEnvironment() {
69 | return environment;
70 | }
71 |
72 | public boolean isDemo() {
73 | return demo;
74 | }
75 |
76 | public boolean isInstallArtifacts() {
77 | return installArtifacts;
78 | }
79 |
80 | @CheckForNull
81 | public String getUpdateCenterUrl() {
82 | return updateCenterUrl;
83 | }
84 | }
--------------------------------------------------------------------------------
/custom-war-packager-cli/src/main/java/io/jenkins/tools/warpackager/cli/Main.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.cli;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.Config;
4 | import io.jenkins.tools.warpackager.lib.impl.Builder;
5 | import org.kohsuke.args4j.CmdLineException;
6 | import org.kohsuke.args4j.CmdLineParser;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 |
11 | public class Main {
12 |
13 | public static void main(String[] args) throws IOException, InterruptedException {
14 | CliOptions options = new CliOptions();
15 | CmdLineParser p = new CmdLineParser(options);
16 | if (args.length == 0) {
17 | System.out.println("Usage: java -jar war-packager-cli.jar -configPath=mywar.yml [-version=1.0-SNAPSHOT] [-tmpDir=tmp]\n");
18 | p.printUsage(System.out);
19 | return;
20 | }
21 |
22 | try {
23 | p.parseArgument(args);
24 | } catch (CmdLineException ex) {
25 | p.printUsage(System.out);
26 | throw new IOException("Failed to read command-line arguments", ex);
27 | }
28 |
29 | final Config cfg;
30 | if (options.isDemo()) {
31 | System.out.println("Running build in the demo mode");
32 | cfg = Config.loadDemoConfig();
33 | } else {
34 | final File configPath = options.getConfigPath();
35 | if (configPath == null) {
36 | throw new IOException("-configPath or -demo must be defined");
37 | }
38 | cfg = Config.loadConfig(configPath);
39 | }
40 |
41 | // Override Build Settings by CLI arguments
42 | cfg.buildSettings.setTmpDir(options.getTmpDir());
43 | cfg.buildSettings.setVersion(options.getVersion());
44 | cfg.buildSettings.setMvnSettingsFile(options.getMvnSettingsFile());
45 | cfg.buildSettings.setBOM(options.getBOMPath());
46 | cfg.buildSettings.setEnvironmentName(options.getEnvironment());
47 | cfg.buildSettings.setInstallArtifacts(options.isInstallArtifacts());
48 | cfg.buildSettings.setUpdateCenterUrl(options.getUpdateCenterUrl());
49 | if (options.batchMode) {
50 | cfg.buildSettings.addMavenOption("--batch-mode");
51 | cfg.buildSettings.addMavenOption("-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn");
52 | }
53 |
54 | new Builder(cfg).build();
55 | }
56 | }
--------------------------------------------------------------------------------
/custom-war-packager-cli/src/main/resources/io/jenkins/tools/warpackager/cli/config/sample.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.github.oleg-nenashev"
3 | artifactId: "mywar"
4 | description: "Just a WAR auto-generation-sample"
5 | war:
6 | groupId: "org.jenkins-ci.main"
7 | artifactId: "jenkins-war"
8 | source:
9 | version: 2.107
10 | plugins:
11 | - groupId: "org.jenkins-ci.plugins"
12 | artifactId: "matrix-project"
13 | source:
14 | version: 1.9
15 | - groupId: "org.jenkins-ci.plugins"
16 | artifactId: "durable-task"
17 | source:
18 | git: https://github.com/jglick/durable-task-plugin.git
19 | branch: watch-JENKINS-38381
20 | systemProperties: {
21 | jenkins.model.Jenkins.slaveAgentPort: "50000",
22 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
23 |
24 | # TODO: Support System Groovy Scripts Bundling
25 |
26 |
--------------------------------------------------------------------------------
/custom-war-packager-cli/src/test/java/io/jenkins/tools/warpackager/cli/MainTest.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.cli;
2 |
3 | import org.junit.Test;
4 | import org.jvnet.hudson.test.For;
5 |
6 | /**
7 | * @author Oleg Nenashev
8 | */
9 | @For(Main.class)
10 | public class MainTest {
11 |
12 | @Test
13 | public void demoShouldPass() throws Exception {
14 | Main.main(new String[] {"-demo"});
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | io.jenkins.tools.custom-war-packager
7 | parent-pom
8 | 2.0-alpha-7-SNAPSHOT
9 |
10 |
11 | custom-war-packager-lib
12 | jar
13 | 2.0-alpha-7-SNAPSHOT
14 |
15 | Jenkins Custom WAR Packager Library
16 | Generates a Custom WAR file from the specified YAML configuration file
17 |
18 |
19 | 2.12.3
20 |
21 |
22 |
23 |
24 |
25 | org.apache.maven
26 | maven-model
27 | ${maven.version}
28 |
29 |
30 |
31 | com.fasterxml.jackson.core
32 | jackson-core
33 | ${fasterxml.jackson.core.version}
34 |
35 |
36 | com.fasterxml.jackson.core
37 | jackson-databind
38 | ${fasterxml.jackson.core.version}
39 |
40 |
41 | com.fasterxml.jackson.dataformat
42 | jackson-dataformat-yaml
43 | 2.12.3
44 |
45 |
46 |
47 | org.apache.commons
48 | commons-lang3
49 | 3.12.0
50 |
51 |
52 | commons-io
53 | commons-io
54 | 2.8.0
55 |
56 |
57 | commons-collections
58 | commons-collections
59 | 3.2.2
60 |
61 |
62 | org.apache.ant
63 | ant
64 | 1.10.10
65 |
66 |
67 | org.kohsuke.stapler
68 | json-lib
69 | 2.4-jenkins-3
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/CasCConfig.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | /**
4 | * Provides integration with Configuration-as-Code plugin.
5 | * @author Oleg Nenashev
6 | * @since TODO
7 | */
8 | public class CasCConfig extends WARResourceInfo {
9 |
10 | public static final String CASC_PLUGIN_ARTIFACT_ID = "configuration-as-code";
11 |
12 | @Override
13 | public String getDestination() {
14 | return "WEB-INF/jenkins.yaml.d";
15 | }
16 |
17 | @Override
18 | public String getResourceType() {
19 | return "jenkins.yaml";
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/DependencyBuildSettings.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 |
5 | /**
6 | * @author Oleg Nenashev
7 | * @since TODO
8 | */
9 | @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON Deserialization")
10 | public class DependencyBuildSettings {
11 |
12 | public static final DependencyBuildSettings DEFAULT = new DependencyBuildSettings();
13 |
14 | public boolean buildOriginalVersion;
15 |
16 | public boolean noCache;
17 | }
18 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/DependencyInfo.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 | import org.apache.commons.lang3.StringUtils;
5 | import org.apache.maven.model.Dependency;
6 |
7 | import javax.annotation.CheckForNull;
8 | import javax.annotation.Nonnull;
9 | import java.io.IOException;
10 | import java.util.Map;
11 |
12 | /**
13 | * @author Oleg Nenashev
14 | * @since TODO
15 | */
16 | @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON Deserialization")
17 | public class DependencyInfo {
18 | public String groupId;
19 | public String artifactId;
20 | public String type;
21 | @CheckForNull
22 | public SourceInfo source;
23 | @CheckForNull
24 | public DependencyBuildSettings build;
25 |
26 | public boolean isNeedsBuild() {
27 | return source != null && !source.isReleasedVersion();
28 | }
29 |
30 | public Dependency toDependency(Map versionOverrides) throws IOException {
31 |
32 | Dependency dep = new Dependency();
33 | dep.setGroupId(groupId);
34 | dep.setArtifactId(artifactId);
35 | if (StringUtils.isNotEmpty(type)) {
36 | dep.setType(type);
37 | }
38 |
39 | String version = versionOverrides.get(artifactId);
40 | if (version == null) {
41 | if (source == null || source.version == null) {
42 | throw new IOException("Source version has not been resolved: " + source);
43 | }
44 | version = source.version;
45 | }
46 |
47 | dep.setVersion(version);
48 | return dep;
49 | }
50 |
51 | @CheckForNull
52 | public SourceInfo getSource() {
53 | return source;
54 | }
55 |
56 | @Override
57 | public String toString() {
58 | return String.format("%s:%s:%s", groupId, artifactId, source);
59 | }
60 |
61 | @Nonnull
62 | public DependencyBuildSettings getBuildSettings() {
63 | return build != null ? build : DependencyBuildSettings.DEFAULT;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/DockerBuildSettings.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import javax.annotation.CheckForNull;
4 | import javax.annotation.Nonnull;
5 |
6 | /**
7 | * Settings for Docker packaging
8 | * @author Oleg Nenashev
9 | */
10 | public class DockerBuildSettings {
11 |
12 | public static final String DEFAULT_BASE = "jenkins/jenkins:lts";
13 | public static final String DEFAULT_OUTPUT_DIR = "docker";
14 |
15 | @CheckForNull
16 | private String base;
17 |
18 | @CheckForNull
19 | private String outputDir;
20 |
21 | private boolean build;
22 |
23 | private boolean buildx;
24 |
25 | private String output;
26 |
27 | @CheckForNull
28 | private String tag;
29 |
30 | /**
31 | * String custom field to store whatever you want.
32 | */
33 | private String customSettings;
34 |
35 | private String platform;
36 |
37 | public void setBase(@CheckForNull String base) {
38 | this.base = base;
39 | }
40 |
41 | public void setOutputDir(@CheckForNull String outputDir) {
42 | this.outputDir = outputDir;
43 | }
44 |
45 | public void setBuild(boolean build) {
46 | this.build = build;
47 | }
48 |
49 | public void setBuildx(boolean buildx) {
50 | this.buildx = buildx;
51 | }
52 |
53 | public void setOutput(String output) {
54 | this.output = output;
55 | }
56 |
57 | public void setTag(@CheckForNull String tag) {
58 | this.tag = tag;
59 | }
60 |
61 | public void setCustomSettings(String customSettings) {
62 | this.customSettings = customSettings;
63 | }
64 |
65 | public void setPlatform(String platform) {
66 | this.platform = platform;
67 | }
68 |
69 | @Nonnull
70 | public String getBase() {
71 | return base != null ? base : DEFAULT_BASE;
72 | }
73 |
74 | @Nonnull
75 | public String getOutputDir() {
76 | return outputDir != null ? outputDir : DEFAULT_OUTPUT_DIR;
77 | }
78 |
79 | public boolean isBuild() {
80 | return build;
81 | }
82 |
83 | public boolean isBuildx() {
84 | return buildx;
85 | }
86 |
87 | public String getOutput() {
88 | return output;
89 | }
90 |
91 | @CheckForNull
92 | public String getTag() {
93 | return tag;
94 | }
95 |
96 | public String getCustomSettings() {
97 | return customSettings;
98 | }
99 |
100 | public String getPlatform() {
101 | return platform;
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/EssentialsYMLConfig.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 |
5 | import javax.annotation.CheckForNull;
6 |
7 | /**
8 | * Wrapper for {@code essentials.yml} configuration files.
9 | * It does not load all properties, but just {@code packaging} section for {@link Config}.
10 | * @author Oleg Nenashev
11 | */
12 | @JsonIgnoreProperties(ignoreUnknown = true)
13 | public class EssentialsYMLConfig {
14 |
15 | @CheckForNull
16 | public Packaging packaging;
17 |
18 | @JsonIgnoreProperties(ignoreUnknown = true)
19 | public static class Packaging {
20 |
21 | @CheckForNull
22 | public Config config;
23 |
24 | @CheckForNull
25 | public String configFile;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/GroovyHookInfo.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 |
5 | /**
6 | * Describes groovy hook to be used.
7 | * @author Oleg Nenashev
8 | */
9 | @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "Comes from YAML")
10 | public class GroovyHookInfo extends WARResourceInfo {
11 | public String type;
12 |
13 | @Override
14 | public String getResourceType() {
15 | return "groovy-hooks." + type;
16 | }
17 |
18 | @Override
19 | public String getDestination() {
20 | return "WEB-INF/" + type + ".groovy.d";
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/JenkinsRepositorySettings.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import javax.annotation.CheckForNull;
4 | import javax.annotation.Nonnull;
5 |
6 | /**
7 | * Settings for Jenkins repository
8 | */
9 | public class JenkinsRepositorySettings {
10 |
11 | public static final String DEFAULT_ID = "repo.jenkins-ci.org";
12 | public static final String DEFAULT_URL = "https://repo.jenkins-ci.org/public/";
13 | public static final String DEFAULT_INCREMENTALS_ID = "incrementals";
14 | public static final String DEFAULT_INCREMENTALS_URL = "https://repo.jenkins-ci.org/incrementals/";
15 |
16 | @CheckForNull
17 | private String id;
18 |
19 | @CheckForNull
20 | private String url;
21 |
22 | @CheckForNull
23 | private String incrementalsId;
24 |
25 | @CheckForNull
26 | private String incrementalsUrl;
27 |
28 | public void setId(@CheckForNull String id) {
29 | this.id = id;
30 | }
31 |
32 | public void setUrl(@CheckForNull String url) {
33 | this.url = url;
34 | }
35 |
36 | public void setIncrementalsId(@CheckForNull String incrementalsId) {
37 | this.incrementalsId = incrementalsId;
38 | }
39 |
40 | public void setIncrementalsUrl(@CheckForNull String incrementalsUrl) {
41 | this.incrementalsUrl = incrementalsUrl;
42 | }
43 |
44 | @Nonnull
45 | public String getId() {
46 | return id != null ? id : DEFAULT_ID;
47 | }
48 |
49 |
50 | @Nonnull
51 | public String getUrl() {
52 | return url != null ? url : DEFAULT_URL;
53 | }
54 |
55 | @Nonnull
56 | public String getIncrementalsId() {
57 | return incrementalsId != null ? incrementalsId : DEFAULT_INCREMENTALS_ID;
58 | }
59 |
60 |
61 | @Nonnull
62 | public String getIncrementalsUrl() {
63 | return incrementalsUrl != null ? incrementalsUrl : DEFAULT_INCREMENTALS_URL;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/JenkinsfileRunnerSettings.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 |
5 | import javax.annotation.CheckForNull;
6 | import javax.annotation.Nonnull;
7 |
8 | /**
9 | * Defines build settings for Jenkinsfile Runner.
10 | * @author Oleg Nenashev
11 | * @since TODO
12 | */
13 | @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR",
14 | justification = "Jackson does it in this case")
15 | public class JenkinsfileRunnerSettings {
16 |
17 | private static final String DEFAULT_WORKSPACE = "/build";
18 |
19 | @Nonnull
20 | private DependencyInfo source;
21 |
22 | @CheckForNull
23 | private DockerBuildSettings docker;
24 |
25 | @CheckForNull
26 | private String runWorkspace;
27 |
28 | private boolean noSandbox;
29 |
30 | public void setSource(@Nonnull DependencyInfo source) {
31 | this.source = source;
32 | }
33 |
34 | public void setDocker(@CheckForNull DockerBuildSettings docker) {
35 | this.docker = docker;
36 | }
37 |
38 | public void setRunWorkspace(@CheckForNull String runWorkspace) {
39 | this.runWorkspace= runWorkspace;
40 | }
41 |
42 | public void setNoSandbox(boolean noSandbox) {
43 | this.noSandbox = noSandbox;
44 | }
45 |
46 | @Nonnull
47 | public DependencyInfo getSource() {
48 | return source;
49 | }
50 |
51 | @CheckForNull
52 | public DockerBuildSettings getDocker() {
53 | return docker;
54 | }
55 |
56 | @Nonnull
57 | public String getRunWorkspace() {
58 | return runWorkspace != null ? runWorkspace : DEFAULT_WORKSPACE;
59 | }
60 |
61 | public boolean isNoSandbox() {
62 | return noSandbox;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/LibraryInfo.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 |
5 | /**
6 | * Abstraction over core libraries that have to be modified via system properties in core at build time
7 | */
8 | @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON Deserialization")
9 | public class LibraryInfo {
10 |
11 | public String property;
12 |
13 | public DependencyInfo source;
14 |
15 | public String getProperty() {
16 | return property;
17 | }
18 |
19 | public DependencyInfo getSource() {
20 | return source;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/PackageInfo.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 |
5 | import javax.annotation.CheckForNull;
6 | import javax.annotation.Nonnull;
7 | import java.util.Collections;
8 | import java.util.Map;
9 |
10 | import static io.jenkins.tools.warpackager.lib.util.CollectionsHelper.putIfNotNull;
11 |
12 | /**
13 | * @author Oleg Nenashev
14 | * @since TODO
15 | */
16 | @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON Deserialization")
17 | public class PackageInfo {
18 | public String groupId;
19 | public String artifactId;
20 |
21 | @CheckForNull
22 | public String vendor;
23 | @CheckForNull
24 | public String title;
25 | @CheckForNull
26 | public String description;
27 |
28 | public void toKeyValueMap(@Nonnull Map dest) {
29 | // TODO(oleg_nenashev): add support of Name from BOM? how is it different from artifactID, what are the requirements?
30 | dest.put("name", artifactId);
31 | dest.put("artifactId", artifactId);
32 | dest.put("groupId", groupId);
33 | putIfNotNull(dest, "vendor", vendor);
34 | putIfNotNull(dest, "title", title);
35 | putIfNotNull(dest, "description", description);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/SourceInfo.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 |
5 | import javax.annotation.CheckForNull;
6 |
7 | /**
8 | * @author Oleg Nenashev
9 | * @since TODO
10 | */
11 | @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON Deserialization")
12 | public class SourceInfo {
13 | public String version;
14 | public String git;
15 | public String branch;
16 | public String commit;
17 | @CheckForNull
18 | public String dir;
19 |
20 | public boolean isReleasedVersion() {
21 | return version != null;
22 | }
23 |
24 | public Type getType() {
25 | if (version != null) {
26 | return Type.MAVEN_REPO;
27 | }
28 |
29 | if (git != null) {
30 | return Type.GIT;
31 | }
32 |
33 | if (dir != null) {
34 | return Type.FILESYSTEM;
35 | }
36 |
37 | return Type.UNKNOWN;
38 | }
39 |
40 | //TODO(oleg_nenashev): rename to getRef()
41 | @CheckForNull
42 | public String getCheckoutId() {
43 | return commit != null ? commit : branch;
44 | }
45 |
46 | @Override
47 | public String toString() {
48 | switch (getType()) {
49 | case MAVEN_REPO:
50 | return version;
51 | case GIT:
52 | return String.format("git: %s, checkout: %s", git, getCheckoutId());
53 | case FILESYSTEM:
54 | return String.format("filesystem: %s", dir);
55 | default:
56 | return "unknown source";
57 | }
58 | }
59 |
60 | public enum Type {
61 | MAVEN_REPO,
62 | GIT,
63 | FILESYSTEM,
64 | UNKNOWN
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/WARResourceInfo.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 |
5 | /**
6 | * Abstraction for all resources being injected into WARs.
7 | * @author Oleg Nenashev
8 | * @since TODO
9 | */
10 | @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON Deserialization")
11 | public abstract class WARResourceInfo {
12 | public String id;
13 | public SourceInfo source;
14 |
15 | public abstract String getResourceType();
16 |
17 | /**
18 | * Gets relative path to the resource within WAR.
19 | */
20 | public abstract String getDestination();
21 | }
22 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/config/WarInfo.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * A war definition can contain only dependency info or also libraries
9 | */
10 |
11 | @SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "JSON Deserialization")
12 | public class WarInfo extends DependencyInfo {
13 |
14 | public List libraries;
15 |
16 | @Override
17 | public boolean isNeedsBuild() {
18 | if (libraries != null && libraries.size() > 0 && source != null && source.getType().equals(SourceInfo.Type.MAVEN_REPO)){
19 | throw new IllegalArgumentException("war libraries are not supported for released versions of jenkins war, use a git source instead");
20 | }
21 | return super.isNeedsBuild() || isLibrariesNeeded();
22 | }
23 |
24 | public boolean isLibrariesNeeded() {
25 | if (libraries == null || libraries.size() == 0) {
26 | return false;
27 | } else {
28 | return true;
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/JenkinsDockerfileBuilder.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.impl;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.Config;
4 | import io.jenkins.tools.warpackager.lib.config.DockerBuildSettings;
5 | import io.jenkins.tools.warpackager.lib.util.DockerfileBuilder;
6 | import io.jenkins.tools.warpackager.lib.util.SystemCommandHelper;
7 | import org.apache.commons.io.IOUtils;
8 |
9 | import javax.annotation.Nonnull;
10 | import java.io.ByteArrayOutputStream;
11 | import java.io.File;
12 | import java.io.FileOutputStream;
13 | import java.io.IOException;
14 | import java.io.PrintStream;
15 | import java.io.UnsupportedEncodingException;
16 | import java.nio.charset.StandardCharsets;
17 | import java.util.logging.Level;
18 | import java.util.logging.Logger;
19 |
20 | /**
21 | * Builds Docker images for WAR.
22 | * This method implies that the base Docker image is compatible with the standard {@code jenkins/jenkins} image.
23 | * @author Oleg Nenashev
24 | */
25 | public class JenkinsDockerfileBuilder extends DockerfileBuilder {
26 |
27 | private static final Logger LOGGER = Logger.getLogger(JenkinsDockerfileBuilder.class.getName());
28 |
29 | public JenkinsDockerfileBuilder(@Nonnull Config config,
30 | @Nonnull DockerBuildSettings docker,
31 | @Nonnull File outputDir) throws IOException {
32 | super(config,
33 | docker,
34 | outputDir);
35 | }
36 |
37 | public JenkinsDockerfileBuilder withPlugins(@Nonnull File pluginsDir) {
38 | if (!pluginsDir.exists()) {
39 | LOGGER.log(Level.INFO, "No plugins to include");
40 | return this;
41 | }
42 |
43 | LOGGER.log(Level.INFO, "Plugins are included into the WAR file, no need to copy them");
44 | return this;
45 | }
46 |
47 | public JenkinsDockerfileBuilder withInitScripts(@Nonnull File rootDir) {
48 | final File[] files = rootDir.listFiles();
49 | if (files == null || files.length == 0) {
50 | return this; // never happens anyway
51 | }
52 |
53 | for (File dir : files) {
54 | if (dir.getName().endsWith(".groovy.d")) {
55 | LOGGER.log(Level.INFO, "Discovered hooks: {0}", dir.getName());
56 | // Do nothing anyway, WAR file is packaged. They will be executed on startup
57 | }
58 | }
59 |
60 | return this;
61 | }
62 |
63 | protected String generateDockerfile() {
64 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
65 | final PrintStream ps;
66 | try {
67 | ps = new PrintStream(baos, true, "UTF-8");
68 | } catch (UnsupportedEncodingException ex) {
69 | throw new IllegalStateException(ex);
70 | }
71 | ps.println("FROM " + dockerSettings.getBase());
72 |
73 | // Labels
74 | StringBuilder labelString = new StringBuilder("LABEL Version=\"");
75 | labelString.append(config.buildSettings.getVersion());
76 | labelString.append("\"");
77 | if (config.bundle.description != null) {
78 | labelString.append("Description=\"");
79 | labelString.append(config.bundle.description);
80 | labelString.append("\"");
81 | }
82 | if (config.bundle.vendor != null) {
83 | labelString.append("Vendor=\"");
84 | labelString.append(config.bundle.vendor);
85 | labelString.append("\"");
86 | }
87 | ps.println(labelString);
88 |
89 | // Core
90 | ps.println("ADD target/" + config.getOutputWar().getName() + " /usr/share/jenkins/jenkins.war");
91 |
92 | ps.println("ENTRYPOINT [\"tini\", \"--\", \"/usr/local/bin/jenkins.sh\"]");
93 | String dockerfile = new String(baos.toByteArray(), StandardCharsets.UTF_8);
94 | return dockerfile;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/POMGenerator.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.impl;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.Config;
4 | import io.jenkins.tools.warpackager.lib.config.JenkinsRepositorySettings;
5 |
6 | import java.nio.charset.StandardCharsets;
7 |
8 | import org.apache.maven.model.Model;
9 | import org.apache.maven.model.Repository;
10 |
11 | /**
12 | * @author Oleg Nenashev
13 | */
14 | public class POMGenerator {
15 |
16 | protected final Config config;
17 |
18 | public POMGenerator(Config config) {
19 | this.config = config;
20 | }
21 |
22 | protected void addRepositories(Model target) {
23 | JenkinsRepositorySettings repositorySettings = config.buildSettings.getJenkinsRepository();
24 | if (repositorySettings == null) {
25 | repositorySettings = new JenkinsRepositorySettings();
26 | }
27 |
28 | // Common repo
29 | Repository jenkinsRepository = new Repository();
30 | jenkinsRepository.setId(repositorySettings.getId());
31 | jenkinsRepository.setUrl(repositorySettings.getUrl());
32 | target.addPluginRepository(jenkinsRepository);
33 | target.addRepository(jenkinsRepository);
34 |
35 | // Incrementals repo
36 | Repository incrementals = new Repository();
37 | incrementals.setId(repositorySettings.getIncrementalsId());
38 | incrementals.setUrl(repositorySettings.getIncrementalsUrl());
39 | target.addPluginRepository(incrementals);
40 | target.addRepository(incrementals);
41 | }
42 |
43 | protected void addUTF8SourceEncodingProperty(Model target) {
44 | target.addProperty("project.build.sourceEncoding", StandardCharsets.UTF_8.toString());
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/PackagerBase.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.impl;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.Config;
4 | import io.jenkins.tools.warpackager.lib.util.MavenHelper;
5 |
6 | /**
7 | * Base class for WAR packaging.
8 | */
9 | public class PackagerBase {
10 |
11 | protected final Config config;
12 | protected final MavenHelper mavenHelper;
13 |
14 | public PackagerBase(Config config) {
15 | this.config = config;
16 | this.mavenHelper = new MavenHelper(config);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/plugins/MavenPluginInfoProvider.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.impl.plugins;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.DependencyInfo;
4 | import io.jenkins.tools.warpackager.lib.config.SourceInfo;
5 | import io.jenkins.tools.warpackager.lib.model.plugins.PluginInfoProvider;
6 | import io.jenkins.tools.warpackager.lib.util.MavenHelper;
7 |
8 | import javax.annotation.Nonnull;
9 | import java.io.File;
10 | import java.io.IOException;
11 |
12 | /**
13 | * Retrieves information about plugins from a Maven repository.
14 | * The implementation uses local caches when needed.
15 | */
16 | public class MavenPluginInfoProvider implements PluginInfoProvider {
17 |
18 | private MavenHelper helper;
19 | private File tmpDir;
20 |
21 | public MavenPluginInfoProvider(@Nonnull MavenHelper helper, @Nonnull File tmpDir) {
22 | this.helper = helper;
23 | this.tmpDir = tmpDir;
24 | }
25 |
26 | @Override
27 | public boolean isPlugin(@Nonnull DependencyInfo dep) throws IOException, InterruptedException {
28 | SourceInfo sourceInfo = dep.getSource();
29 | if (sourceInfo == null) {
30 | throw new IOException("No Source info provided for " + dep);
31 | }
32 | return helper.artifactExistsInLocalCache(dep, sourceInfo.version, "hpi") ||
33 | helper.artifactExists(tmpDir, dep, sourceInfo.version, "hpi");
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/impl/plugins/UpdateCenterPluginInfoProvider.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.impl.plugins;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.DependencyInfo;
4 | import io.jenkins.tools.warpackager.lib.model.plugins.PluginInfoProvider;
5 | import net.sf.json.JSONObject;
6 | import org.apache.commons.io.IOUtils;
7 |
8 | import javax.annotation.Nonnull;
9 | import java.io.IOException;
10 | import java.net.URL;
11 | import java.util.HashMap;
12 | import java.util.Map;
13 | import java.util.Set;
14 | import java.util.logging.Level;
15 | import java.util.logging.Logger;
16 |
17 | public class UpdateCenterPluginInfoProvider implements PluginInfoProvider {
18 |
19 | public static final String DEFAULT_JENKINS_UC_URL = "https://updates.jenkins.io/update-center.json";
20 | private static final Logger LOGGER = Logger.getLogger(UpdateCenterPluginInfoProvider.class.getName());
21 |
22 | private String updateCenterUrl;
23 | private Map groupIdCache;
24 |
25 | public UpdateCenterPluginInfoProvider(@Nonnull String updateCenterUrl) {
26 | this.updateCenterUrl = updateCenterUrl;
27 | }
28 |
29 | @Override
30 | public void init() throws IOException, InterruptedException {
31 | groupIdCache = extractUpdateCenterData(new URL(updateCenterUrl));
32 | }
33 |
34 | @Override
35 | public boolean isPlugin(@Nonnull DependencyInfo dependency) throws IOException, InterruptedException {
36 | boolean isPlugin = groupIdCache.containsKey(dependency.artifactId);
37 | LOGGER.log(Level.FINE, "Checking whether {0} is a plugin: {1}",
38 | new Object[] {dependency.artifactId, isPlugin});
39 | return isPlugin;
40 | }
41 |
42 | private static Map extractUpdateCenterData(URL url) throws IOException {
43 | Map groupIDs = new HashMap<>();
44 | String jsonp = null;
45 | try {
46 | jsonp = IOUtils.toString(url.openStream());
47 | } catch(IOException e){
48 | throw new IOException("Invalid update center url : " + url, e);
49 | }
50 |
51 | String json = jsonp.substring(jsonp.indexOf('(')+1,jsonp.lastIndexOf(')'));
52 | JSONObject jsonObj = JSONObject.fromObject(json);
53 |
54 | // UpdateSite.Plugin does not contain gav object, so we process the JSON object on our own here
55 | for(Map.Entry e : (Set>)jsonObj.getJSONObject("plugins").entrySet()) {
56 | String gav = e.getValue().getString("gav");
57 | String groupId = gav.split(":")[0];
58 | groupIDs.putIfAbsent(e.getKey(), groupId);
59 | }
60 | return groupIDs;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/model/bom/BOM.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.model.bom;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import com.fasterxml.jackson.databind.ObjectMapper;
5 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
6 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
7 | import io.jenkins.tools.warpackager.lib.config.Config;
8 |
9 | import javax.annotation.CheckForNull;
10 | import javax.annotation.Nonnull;
11 | import java.io.File;
12 | import java.io.FileInputStream;
13 | import java.io.FileNotFoundException;
14 | import java.io.FileOutputStream;
15 | import java.io.IOException;
16 | import java.io.InputStream;
17 | import java.io.OutputStream;
18 |
19 | /**
20 | * Defines BOM structure according to Jenkins JEP-TODO.
21 | * @author Oleg Nenashev
22 | * @since TODO
23 | */
24 | @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "Fields come from JSON")
25 | public class BOM {
26 |
27 | @CheckForNull
28 | Metadata metadata;
29 |
30 | @Nonnull
31 | @JsonProperty(required = true)
32 | public Specification spec;
33 |
34 | @CheckForNull
35 | Specification status;
36 |
37 | public void setMetadata(@CheckForNull Metadata metadata) {
38 | this.metadata = metadata;
39 | }
40 |
41 | public void setSpec(@Nonnull Specification spec) {
42 | this.spec = spec;
43 | }
44 |
45 | public void setStatus(@CheckForNull Specification status) {
46 | this.status = status;
47 | }
48 |
49 | @CheckForNull
50 | public Metadata getMetadata() {
51 | return metadata;
52 | }
53 |
54 | @Nonnull
55 | public Specification getSpec() {
56 | return spec;
57 | }
58 |
59 | @CheckForNull
60 | public Specification getStatus() {
61 | return status;
62 | }
63 |
64 | public void write(@Nonnull File configPath) throws IOException {
65 | try (FileOutputStream ostream = new FileOutputStream(configPath)) {
66 | write(ostream);
67 | }
68 | }
69 |
70 | public void write(@Nonnull OutputStream ostream) throws IOException {
71 | ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
72 | mapper.writeValue(ostream, this);
73 | }
74 |
75 | public static BOM load(@Nonnull File configPath) throws IOException {
76 | if (configPath.exists() && configPath.isFile()) {
77 | try (FileInputStream istream = new FileInputStream(configPath)) {
78 | return load(istream);
79 | }
80 | }
81 | throw new FileNotFoundException("Cannot find the BOM file " + configPath);
82 | }
83 |
84 | public static BOM load(@Nonnull InputStream istream) throws IOException {
85 | ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
86 | BOM loaded = mapper.readValue(istream, BOM.class);
87 | //if (loaded.spec == null) {
88 | // throw new IOException("BOM Specification must be present");
89 | //}
90 | return loaded;
91 | }
92 |
93 | public static BOM load(Class> clazz, String resource) throws IOException {
94 | try (InputStream istream = clazz.getResourceAsStream(resource)) {
95 | if (istream == null) {
96 | throw new FileNotFoundException(String.format("Cannot load BOM from the resource file: %s/%s", clazz, resource));
97 | }
98 | return load(istream);
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/model/bom/ComponentReference.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.model.bom;
2 |
3 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
4 | import io.jenkins.tools.warpackager.lib.config.DependencyInfo;
5 | import io.jenkins.tools.warpackager.lib.config.SourceInfo;
6 | import io.jenkins.tools.warpackager.lib.config.WarInfo;
7 |
8 | import javax.annotation.CheckForNull;
9 | import javax.annotation.Nonnull;
10 | import java.util.Map;
11 |
12 | /**
13 | * @author Oleg Nenashev
14 | * @since TODO
15 | */
16 | @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "Fields come from JSON")
17 | public class ComponentReference extends Reference {
18 |
19 | //TODO: properties are not required for the core
20 |
21 | @Nonnull
22 | // @JsonProperty(required = true)
23 | String groupId;
24 |
25 | @Nonnull
26 | // @JsonProperty(required = true)
27 | String artifactId;
28 |
29 | @Nonnull
30 | public String getArtifactId() {
31 | return artifactId;
32 | }
33 |
34 | @Nonnull
35 | public String getGroupId() {
36 | return groupId;
37 | }
38 |
39 | public void setArtifactId(@Nonnull String artifactId) {
40 | this.artifactId = artifactId;
41 | }
42 |
43 | public void setGroupId(@Nonnull String groupId) {
44 | this.groupId = groupId;
45 | }
46 |
47 | public WarInfo toWARDependencyInfo() {
48 | WarInfo dep = new WarInfo();
49 | dep.groupId = "org.jenkins-ci.main";
50 | dep.artifactId = "jenkins-war";
51 |
52 | dep.source = new SourceInfo();
53 | if (version != null) {
54 | dep.source.version = version;
55 | } else {
56 | //TODO(oleg_nenashev): we have to interpolate Git repo now, not defined in BOM
57 | dep.source.git = "https://github.com/jenkinsci/" + dep.artifactId + "-plugin.git";
58 | dep.source.branch = ref; // It may be actually commit as well, but the CWP's logic will work
59 | }
60 |
61 | if (dir != null) {
62 | dep.source.dir = dir;
63 | }
64 | return dep;
65 | }
66 |
67 | public DependencyInfo toDependencyInfo() {
68 | DependencyInfo dep = new DependencyInfo();
69 | dep.groupId = groupId;
70 | dep.artifactId = artifactId;
71 |
72 | dep.source = new SourceInfo();
73 | if (version != null) {
74 | dep.source.version = version;
75 | } else {
76 | //TODO(oleg_nenashev): we have to interpolate Git repo now, not defined in BOM
77 | dep.source.git = "https://github.com/jenkinsci/" + dep.artifactId + "-plugin.git";
78 | dep.source.branch = ref; // It may be actually commit as well, but the CWP's logic will work
79 | }
80 |
81 | if (dir != null) {
82 | dep.source.dir = dir;
83 | }
84 | return dep;
85 | }
86 |
87 | @Nonnull
88 | public static ComponentReference resolveFrom(@Nonnull DependencyInfo dep) {
89 | return resolveFrom(dep, false, null);
90 | }
91 |
92 | @Nonnull
93 | public static ComponentReference resolveFrom(@Nonnull DependencyInfo dep, boolean overrideVersions,
94 | @CheckForNull Map versionOverrides) {
95 | ComponentReference ref = new ComponentReference();
96 | ref.setGroupId(dep.groupId);
97 | ref.setArtifactId(dep.artifactId);
98 | //TODO(oleg_nenashev): BOM says "the realized BoM after refs are resolved" when versions are resolved
99 | if (dep.source == null) {
100 | throw new IllegalStateException("Source is not defined for dependency " + dep);
101 | }
102 |
103 | // Not putting ref then
104 | ref.setRef(dep.source.getCheckoutId());
105 | String effectiveVersion = dep.source.version;
106 | if (overrideVersions && versionOverrides != null && versionOverrides.containsKey(dep.artifactId)) {
107 | effectiveVersion = versionOverrides.get(dep.artifactId);
108 | }
109 | ref.setVersion(effectiveVersion);
110 |
111 | return ref;
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/model/bom/Environment.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.model.bom;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
5 |
6 | import javax.annotation.CheckForNull;
7 | import javax.annotation.Nonnull;
8 | import java.util.Collections;
9 | import java.util.List;
10 |
11 | /**
12 | * @author Oleg Nenashev
13 | * @since TODO
14 | */
15 | @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "Fields come from JSON")
16 | public class Environment {
17 |
18 | @Nonnull
19 | @JsonProperty(required = true)
20 | String name;
21 |
22 | @CheckForNull
23 | List components;
24 |
25 | @CheckForNull
26 | List plugins;
27 |
28 | @Nonnull
29 | public String getName() {
30 | return name;
31 | }
32 |
33 | @Nonnull
34 | public List getComponents() {
35 | return components != null ? components : Collections.emptyList();
36 | }
37 |
38 | @Nonnull
39 | public List getPlugins() {
40 | return plugins != null ? plugins : Collections.emptyList();
41 | }
42 |
43 | public void setName(@Nonnull String name) {
44 | this.name = name;
45 | }
46 |
47 | public void setComponents(@CheckForNull List components) {
48 | this.components = components;
49 | }
50 |
51 | public void setPlugins(@CheckForNull List plugins) {
52 | this.plugins = plugins;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/model/bom/Metadata.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.model.bom;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import io.jenkins.tools.warpackager.lib.config.PackageInfo;
5 |
6 | import javax.annotation.CheckForNull;
7 | import javax.annotation.Nonnull;
8 | import java.io.IOException;
9 | import java.util.Collections;
10 | import java.util.Map;
11 |
12 | import static io.jenkins.tools.warpackager.lib.util.CollectionsHelper.getOrFail;
13 |
14 | /**
15 | *
16 | * @author Oleg Nenashev
17 | * @since TODO
18 | */
19 | public class Metadata {
20 |
21 | @CheckForNull
22 | @JsonProperty
23 | Map labels;
24 |
25 | @CheckForNull
26 | @JsonProperty
27 | Map annotations;
28 |
29 | public void setAnnotations(@CheckForNull Map annotations) {
30 | this.annotations = annotations;
31 | }
32 |
33 | public void setLabels(@CheckForNull Map labels) {
34 | this.labels = labels;
35 | }
36 |
37 | @Nonnull
38 | public Map getAnnotations() {
39 | return annotations != null ? annotations : Collections.emptyMap();
40 | }
41 |
42 | @Nonnull
43 | public Map getLabels() {
44 | return labels != null ? labels : Collections.emptyMap();
45 | }
46 |
47 | @CheckForNull
48 | public PackageInfo toPackageInfo() throws IOException {
49 | if (labels == null) {
50 | return null;
51 | }
52 |
53 | PackageInfo pi = new PackageInfo();
54 | pi.groupId = getOrFail(labels, "groupId", "BOM Metadata labels");
55 | pi.artifactId = getOrFail(labels, "artifactId", "BOM Metadata labels");
56 | pi.vendor = labels.get("vendor");
57 | pi.description = labels.getOrDefault("description", labels.get("name"));
58 | pi.title = labels.getOrDefault("title", labels.get("name"));
59 | return pi;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/model/bom/Reference.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.model.bom;
2 |
3 | import javax.annotation.CheckForNull;
4 |
5 | /**
6 | * @author Oleg Nenashev
7 | * @since TODO
8 | */
9 | public class Reference {
10 |
11 | @CheckForNull
12 | String ref;
13 |
14 | @CheckForNull
15 | String version;
16 |
17 | @CheckForNull
18 | String dir;
19 |
20 | public void setVersion(@CheckForNull String version) {
21 | this.version = version;
22 | }
23 |
24 | public void setRef(@CheckForNull String ref) {
25 | this.ref = ref;
26 | }
27 |
28 | public void setDir(@CheckForNull String dir) {
29 | this.dir = dir;
30 | }
31 |
32 | @CheckForNull
33 | public String getRef() {
34 | return ref;
35 | }
36 |
37 | @CheckForNull
38 | public String getVersion() {
39 | return version;
40 | }
41 |
42 | @CheckForNull
43 | public String getDir() {
44 | return dir;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/model/bom/Specification.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.model.bom;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
5 |
6 | import javax.annotation.CheckForNull;
7 | import javax.annotation.Nonnull;
8 | import java.util.Collections;
9 | import java.util.List;
10 |
11 | /**
12 | * @author Oleg Nenashev
13 | * @since TODO
14 | */
15 | @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "Fields come from JSON")
16 | public class Specification {
17 |
18 | @Nonnull
19 | @JsonProperty(required = true)
20 | ComponentReference core;
21 |
22 | @CheckForNull
23 | List components;
24 |
25 | @CheckForNull
26 | List plugins;
27 |
28 | @CheckForNull
29 | List environments;
30 |
31 | public void setCore(ComponentReference core) {
32 | this.core = core;
33 | }
34 |
35 | public void setComponents(@CheckForNull List components) {
36 | this.components = components;
37 | }
38 |
39 | public void setPlugins(@CheckForNull List plugins) {
40 | this.plugins = plugins;
41 | }
42 |
43 | public void setEnvironments(@CheckForNull List environments) {
44 | this.environments = environments;
45 | }
46 |
47 | @CheckForNull
48 | public Environment getEnvironment(@Nonnull String name) {
49 | if (environments == null) {
50 | return null;
51 | }
52 |
53 | for (Environment env : environments) {
54 | if (name.equals(env.name)) {
55 | return env;
56 | }
57 | }
58 | return null;
59 | }
60 |
61 | @Nonnull
62 | public ComponentReference getCore() {
63 | return core;
64 | }
65 |
66 | @Nonnull
67 | public List getPlugins() {
68 | return plugins != null ? plugins : Collections.emptyList();
69 | }
70 |
71 | @Nonnull
72 | public List getComponents() {
73 | return components != null ? components : Collections.emptyList();
74 | }
75 |
76 | @Nonnull
77 | public List getEnvironments() {
78 | return environments != null ? environments : Collections.emptyList();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/model/plugins/PluginInfoProvider.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.model.plugins;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.DependencyInfo;
4 | import io.jenkins.tools.warpackager.lib.impl.plugins.MavenPluginInfoProvider;
5 | import io.jenkins.tools.warpackager.lib.impl.plugins.UpdateCenterPluginInfoProvider;
6 |
7 | import javax.annotation.Nonnull;
8 | import java.io.IOException;
9 |
10 | /**
11 | * Plugin Information provider.
12 | * The implementations can be used to query various data about plugins.
13 | * @see MavenPluginInfoProvider
14 | * @see UpdateCenterPluginInfoProvider
15 | * @since TODO
16 | */
17 | public interface PluginInfoProvider {
18 |
19 | public static final PluginInfoProvider DEFAULT = new UpdateCenterPluginInfoProvider(UpdateCenterPluginInfoProvider.DEFAULT_JENKINS_UC_URL);
20 |
21 | /**
22 | * Initializes the plugin info source
23 | * @throws IOException Execution failure
24 | * @throws InterruptedException Execution was interrupted
25 | */
26 | default void init() throws IOException, InterruptedException {
27 | //NOOP
28 | }
29 |
30 | /**
31 | * Check whether the dependency is an existing plugin available from the specified source.
32 | * @param dependency Dependency to check
33 | * @return {@code true} if the provider can confirm that the extension is a plugin.
34 | * {@code false} otherwise, even if there is no conclusive response
35 | * @throws IOException Execution failure
36 | * @throws InterruptedException Execution was interrupted
37 | */
38 | public boolean isPlugin(@Nonnull DependencyInfo dependency) throws IOException, InterruptedException;
39 | }
40 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/util/CollectionsHelper.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.util;
2 |
3 | import javax.annotation.CheckForNull;
4 | import javax.annotation.Nonnull;
5 | import java.io.IOException;
6 | import java.util.Map;
7 |
8 | /**
9 | * @author Oleg Nenashev
10 | * @since TODO
11 | */
12 | public class CollectionsHelper {
13 |
14 | @CheckForNull
15 | public static V putIfNotNull(@Nonnull Map dest, @Nonnull K key, @CheckForNull V value) {
16 | if (value != null) {
17 | return dest.put(key, value);
18 | }
19 | return dest.get(key);
20 | }
21 |
22 | @CheckForNull
23 | public static V getOrFail(@Nonnull Map src, @Nonnull K key, @Nonnull String where) throws IOException {
24 | V value = src.get(key);
25 | if (value == null) {
26 | throw new IOException("Cannot find mandatory key " + key + " in " + where);
27 | }
28 | return value;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/util/DockerfileBuilder.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.util;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.Config;
4 | import io.jenkins.tools.warpackager.lib.config.DockerBuildSettings;
5 | import org.apache.commons.io.IOUtils;
6 |
7 | import javax.annotation.Nonnull;
8 | import java.io.ByteArrayOutputStream;
9 | import java.io.File;
10 | import java.io.FileOutputStream;
11 | import java.io.IOException;
12 | import java.io.PrintStream;
13 | import java.io.UnsupportedEncodingException;
14 | import java.nio.charset.StandardCharsets;
15 | import java.util.logging.Level;
16 | import java.util.logging.Logger;
17 |
18 | /**
19 | * Builds Docker images for WAR.
20 | * This method implies that the base Docker image is compatible with the standard {@code jenkins/jenkins} image.
21 | * @author Oleg Nenashev
22 | */
23 | public abstract class DockerfileBuilder {
24 |
25 | protected final Config config;
26 | protected final DockerBuildSettings dockerSettings;
27 | protected final File outputDir;
28 |
29 | private static final Logger LOGGER = Logger.getLogger(DockerfileBuilder.class.getName());
30 |
31 | public DockerfileBuilder(@Nonnull Config config,
32 | @Nonnull DockerBuildSettings dockerSettings,
33 | @Nonnull File outputDir) throws IOException {
34 | this.config = config;
35 | this.dockerSettings = dockerSettings;
36 | if (dockerSettings == null) {
37 | throw new IOException("Docker settings are not defined");
38 | }
39 | this.outputDir = outputDir;
40 | }
41 |
42 | /**
43 | * Builds Dockerfile and prepares all resources
44 | */
45 | public void build() throws IOException, InterruptedException {
46 | LOGGER.log(Level.INFO, "Generating Dockerfile");
47 | String dockerfile = generateDockerfile();
48 | try(FileOutputStream ostream = new FileOutputStream(new File(outputDir, "Dockerfile"))) {
49 | IOUtils.write(dockerfile, ostream, "UTF-8");
50 | }
51 |
52 | if (!dockerSettings.isBuild()) {
53 | return;
54 | }
55 | String tag = dockerSettings.getTag();
56 | if (tag == null) {
57 | throw new IOException("Cannot build Docker image, tag is not defined");
58 | }
59 | LOGGER.log(Level.INFO, "Building Docker image {0}", tag);
60 | if (dockerSettings.isBuildx()) {
61 | String output;
62 | switch (dockerSettings.getOutput()) {
63 | case "push":
64 | // the image push into remote registry directly
65 | output = "--push";
66 | break;
67 | case "load":
68 | // store the docker image into local docker daemon, it can be listed via docker images
69 | output = "--load";
70 | break;
71 | default:
72 | // the image exists as a local cache, it cannot be listed via docker images
73 | output = "";
74 | break;
75 | }
76 | SystemCommandHelper.processFor(outputDir, "docker", "buildx", "build", "--platform",
77 | dockerSettings.getPlatform(), output, "-t", tag, ".");
78 | } else {
79 | SystemCommandHelper.processFor(outputDir, "docker", "build", "-t", tag, ".");
80 | }
81 | }
82 |
83 | protected abstract String generateDockerfile() throws IOException, InterruptedException;
84 | }
85 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/java/io/jenkins/tools/warpackager/lib/util/SystemCommandHelper.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.util;
2 |
3 | import org.apache.commons.io.IOUtils;
4 | import org.apache.commons.lang3.StringUtils;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 | import java.nio.charset.Charset;
9 | import java.util.Arrays;
10 | import java.util.stream.Stream;
11 |
12 | /**
13 | * @author Oleg Nenashev
14 | * @since TODO
15 | */
16 | public class SystemCommandHelper {
17 |
18 | // https://stackoverflow.com/a/228499
19 | private static final String OS_NAME = System.getProperty("os.name");
20 | private static final boolean IS_WINDOWS = OS_NAME != null && OS_NAME.startsWith("Windows");
21 | //https://stackoverflow.com/a/17120829
22 | private static final String[] WINDOWS_PROCESS_ARGS_PREFIX = {"cmd.exe", "/C"};
23 |
24 | private SystemCommandHelper() {}
25 |
26 | private static ProcessBuilder createProcessBuilder(final String[] args) {
27 | String[] combined = args;
28 | if (IS_WINDOWS) {
29 | combined = Stream.concat(Arrays.stream(WINDOWS_PROCESS_ARGS_PREFIX), Arrays.stream(args))
30 | .toArray(String[]::new);
31 | }
32 | return new ProcessBuilder(combined);
33 | }
34 |
35 | public static void processFor(File buildDir, String ... args) throws IOException, InterruptedException {
36 | ProcessBuilder bldr = createProcessBuilder(args).inheritIO();
37 | int res = runFor(buildDir, args);
38 | if (res != 0) {
39 | throw new IOException("Command failed with exit code " + res + ": " + StringUtils.join(bldr.command(), ' '));
40 | }
41 | }
42 |
43 | public static int runFor(File buildDir, String ... args) throws IOException, InterruptedException {
44 | ProcessBuilder bldr = createProcessBuilder(args).inheritIO();
45 | bldr.directory(buildDir);
46 | return bldr.start().waitFor();
47 | }
48 |
49 | public static String readFor(File buildDir, String ... args) throws IOException, InterruptedException {
50 | ProcessBuilder bldr = createProcessBuilder(args);
51 | bldr.directory(buildDir);
52 | Process proc = bldr.start();
53 | int res = proc.waitFor();
54 | String out = IOUtils.toString(proc.getInputStream(), Charset.defaultCharset()).trim();
55 | if (res != 0) {
56 | throw new IOException("Command failed with exit code " + res + ": " + StringUtils.join(bldr.command(), ' ') + ". " + out);
57 | }
58 | return out;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/main/resources/io/jenkins/tools/warpackager/lib/config/sample.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.github.oleg-nenashev"
3 | artifactId: "mywar"
4 | vendor: "Custom WAR Packager"
5 | title: "MyWAR (built by Custom WAR Packager)"
6 | description: "Just a WAR auto-generation-sample"
7 | war:
8 | groupId: "org.jenkins-ci.main"
9 | artifactId: "jenkins-war"
10 | source:
11 | version: 2.107
12 | plugins:
13 | - groupId: "org.jenkins-ci.plugins"
14 | artifactId: "matrix-project"
15 | source:
16 | version: 1.9
17 | - groupId: "org.jenkins-ci.plugins"
18 | artifactId: "durable-task"
19 | source:
20 | version: 1.26
21 | libPatches:
22 | - groupId: "org.jenkins-ci"
23 | artifactId: "task-reactor"
24 | source:
25 | git: https://github.com/jenkinsci/lib-task-reactor.git
26 | systemProperties: {
27 | jenkins.model.Jenkins.slaveAgentPort: "50000",
28 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
29 |
30 |
31 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/test/java/io/jenkins/tools/warpackager/lib/config/ConfigTest.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.config;
2 |
3 | import org.junit.Test;
4 | import org.jvnet.hudson.test.For;
5 |
6 | import static org.junit.Assert.assertEquals;
7 | import static org.junit.Assert.assertNotNull;
8 |
9 | /**
10 | * Verifies the configuration management in the library
11 | * @author Oleg Nenashev
12 | */
13 | @For(Config.class)
14 | public class ConfigTest {
15 |
16 | @Test
17 | public void shouldBeAbleToLoadDefaultsFromSample() throws Exception {
18 | Config cfg = Config.loadDemoConfig();
19 | assertEquals("mywar", cfg.bundle.artifactId);
20 | assertEquals("jenkins-war", cfg.war.artifactId);
21 | assertNotNull("Build settings should be initialized with defaults", cfg.buildSettings);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/test/java/io/jenkins/tools/warpackager/lib/model/bom/BOMTest.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.lib.model.bom;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.Config;
4 | import io.jenkins.tools.warpackager.lib.impl.BOMBuilder;
5 | import org.junit.Rule;
6 | import org.junit.Test;
7 | import org.junit.rules.TemporaryFolder;
8 | import org.jvnet.hudson.test.For;
9 |
10 | import java.io.File;
11 | import java.io.IOException;
12 | import java.util.HashMap;
13 | import java.util.Map;
14 |
15 | import static org.junit.Assert.*;
16 |
17 | @For(BOM.class)
18 | public class BOMTest {
19 |
20 | @Rule
21 | public TemporaryFolder tmp = new TemporaryFolder();
22 |
23 | @Test
24 | public void roundtrip() throws IOException {
25 | BOM bom = BOM.load(BOMTest.class, "BOM.yml");
26 | spotcheck(bom);
27 |
28 | File target = new File(tmp.getRoot(), "bom.yml");
29 | bom.write(target);
30 | BOM reloaded = BOM.load(target);
31 | spotcheck(reloaded);
32 | }
33 |
34 | private void spotcheck(BOM bom) throws AssertionError {
35 | assertNotNull(bom.metadata);
36 | assertNotNull(bom.spec.core);
37 | assertNotNull(bom.spec.plugins);
38 | assertNotNull(bom.spec.environments);
39 | assertEquals("aws", bom.spec.environments.get(0).name);
40 | }
41 |
42 | @Test
43 | public void shouldProduceBOMfromConfig() throws Exception {
44 | Config cfg = Config.loadDemoConfig();
45 | Map overrides = new HashMap<>();
46 | BOMBuilder bldr = new BOMBuilder(cfg).withStatus(overrides);
47 | BOM bom = bldr.build();
48 |
49 | File target = new File(tmp.getRoot(), "bom.yml");
50 | bom.write(target);
51 |
52 | BOM reloaded = BOM.load(target);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/custom-war-packager-lib/src/test/resources/io/jenkins/tools/warpackager/lib/model/bom/BOM.yml:
--------------------------------------------------------------------------------
1 | metadata:
2 | # labels and annotations are key: value string attributes
3 | labels:
4 | name: myplugin
5 | groupId: TODO_whatisit
6 | artifactId: TODO_whatisit
7 | version: 1.0
8 | annotations:
9 | io.jenkins.x: y
10 | spec:
11 | core:
12 | # version OR version + ref (version just to keep Maven happy about version order)
13 | ref: master
14 | version: 1.0
15 | components:
16 | - groupId: org.acme
17 | artifactId: acme-component
18 | ref: master
19 | plugins:
20 | - groupId: org.acme
21 | artifactId: acme-plugin
22 | ref: master
23 | # version: 1.0
24 | environments:
25 | # environments get added to the other section when enabled
26 | - name: aws
27 | plugins:
28 | - groupId: org.acme
29 | artifactId: acme2-plugin
30 | ref: master
31 | # version: 1.0
32 | components:
33 | - groupId: org.acme
34 | artifactId: acme-component2
35 | version: 1.0
36 | # other sections can be added and ignored by default
37 | # the realized BoM after refs are resolved
38 | status:
39 | core:
40 | ref: aaabbb
41 | # version: 1.0
42 | plugins:
43 | - groupId: org.acme
44 | artifactId: acme-plugin
45 | ref: bbbccc
46 | # version: 1.0
47 | environments:
48 | - name: aws
49 | plugins:
50 | - groupId: org.acme
51 | artifactId: acme2-plugin
52 | ref: cccddd
53 | # version: 1.0
54 |
55 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/bom/bom.yml:
--------------------------------------------------------------------------------
1 | metadata:
2 | # labels and annotations are key: value string attributes
3 | labels:
4 | name: bom-it
5 | groupId: io.github.oleg-nenashev
6 | artifactId: mywar
7 | version: 1.0
8 | spec:
9 | core:
10 | version: 2.118
11 | plugins:
12 | - groupId: "org.jenkins-ci.plugins.workflow"
13 | artifactId: "workflow-api"
14 | version: 2.28-20180427.142849-2
15 | - groupId: "org.jenkins-ci.plugins"
16 | artifactId: "copyartifact"
17 | version: 1.40-20180427.143131-1
18 | - groupId: "org.jenkins-ci.plugins"
19 | artifactId: "structs"
20 | version: 1.14
21 | - groupId: "org.jenkins-ci.plugins.workflow"
22 | artifactId: "workflow-step-api"
23 | version: 2.14
24 | - groupId: "org.jenkins-ci.plugins.workflow"
25 | artifactId: "workflow-job"
26 | version: 2.20
27 | - groupId: "org.jenkins-ci.plugins.workflow"
28 | artifactId: "workflow-basic-steps"
29 | version: 2.7
30 | - groupId: "org.jenkins-ci.plugins.workflow"
31 | artifactId: "workflow-support"
32 | version: 2.18
33 | - groupId: "org.jenkins-ci.plugins"
34 | artifactId: "junit"
35 | version: 1.24
36 | - groupId: "org.jenkins-ci.plugins"
37 | artifactId: "mailer"
38 | version: 1.21
39 | - groupId: "org.jenkins-ci.plugins"
40 | artifactId: "scm-api"
41 | version: 2.2.7
42 | - groupId: "org.jenkins-ci.plugins"
43 | artifactId: "script-security"
44 | version: 1.44
45 | environments:
46 | - name: aws
47 | plugins:
48 | - groupId: "io.jenkins.plugins"
49 | artifactId: "artifact-manager-s3"
50 | version: 1.0
51 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/bom/config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.github.oleg-nenashev"
3 | artifactId: "mywar"
4 | description: "Just a WAR auto-generation-sample"
5 | bomIncludeWar: true
6 | war:
7 | groupId: "org.jenkins-ci.main"
8 | artifactId: "jenkins-war"
9 | source:
10 | version: 2.107
11 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/bom/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean package
2 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/bom/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | io.jenkins.tools.war-packager.its
7 | bom
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 |
13 | ${project.artifactId}
14 |
15 |
16 | @project.groupId@
17 | @project.artifactId@
18 | @project.version@
19 |
20 |
21 | package
22 |
23 | custom-war
24 |
25 |
26 | config.yml
27 | bom.yml
28 | aws
29 | 1.1-SNAPSHOT
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/casc/bom.yml:
--------------------------------------------------------------------------------
1 | metadata:
2 | # labels and annotations are key: value string attributes
3 | labels:
4 | name: bom-it
5 | groupId: io.github.oleg-nenashev
6 | artifactId: mywar
7 | version: 1.0
8 | spec:
9 | core:
10 | version: 2.138.3
11 | plugins:
12 | # reproduces JENKINS-54340
13 | - groupId: "io.jenkins"
14 | artifactId: "configuration-as-code"
15 | version: 1.3
16 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/casc/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | systemMessage: "Custom War Packager - Demo of Configuration-as-Code plugin"
3 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/casc/config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.github.oleg-nenashev"
3 | artifactId: "mywar"
4 | description: "Just a WAR auto-generation-sample"
5 | war:
6 | groupId: "org.jenkins-ci.main"
7 | artifactId: "jenkins-war"
8 | source:
9 | version: 2.107
10 | casc:
11 | - id: "casc"
12 | source:
13 | dir: casc.yml
14 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/casc/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean package
2 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/casc/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | io.jenkins.tools.war-packager.its
7 | bom
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 |
13 | ${project.artifactId}
14 |
15 |
16 | @project.groupId@
17 | @project.artifactId@
18 | @project.version@
19 |
20 |
21 | package
22 |
23 | custom-war
24 |
25 |
26 | config.yml
27 | bom.yml
28 | aws
29 | 1.1-SNAPSHOT
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/custom-uc/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | systemMessage: "Custom War Packager - Demo of Configuration-as-Code plugin"
3 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/custom-uc/config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.it"
3 | artifactId: "custom-uc"
4 | description: "CWP Integration Test: Custom Update Center source"
5 | # TODO: This test does not really do anything except a smoke test
6 | # Some infrastructure patches are needed to test the custom UC (e.g. a stable name for an experimental-only plugin)
7 | buildSettings:
8 | pom: "pom.xml"
9 | updateCenterUrl: "https://updates.jenkins.io/experimental/update-center.json"
10 | pomIgnoreRoot: "true"
11 | war:
12 | groupId: "org.jenkins-ci.main"
13 | artifactId: "jenkins-war"
14 | source:
15 | version: 2.176.1
16 | casc:
17 | - id: "casc"
18 | source:
19 | dir: casc.yml
20 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/custom-uc/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean package
2 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/custom-uc/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | io.jenkins.tools.war-packager.its
7 | pom
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 |
13 |
14 | io.jenkins
15 | configuration-as-code
16 | 1.20
17 |
18 |
19 | org.jenkins-ci.plugins
20 | role-strategy
21 | 2.11
22 |
23 |
24 | org.jenkins-ci.plugins
25 | cloudbees-folder
26 | 6.6
27 |
28 |
29 |
30 |
31 | ${project.artifactId}
32 |
33 |
34 | @project.groupId@
35 | @project.artifactId@
36 | @project.version@
37 |
38 |
39 | package
40 |
41 | custom-war
42 |
43 |
44 | config.yml
45 | bom.yml
46 | aws
47 | 1.1-SNAPSHOT
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | repo.jenkins-ci.org
58 | https://repo.jenkins-ci.org/public/
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/incrementals/config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.github.oleg-nenashev"
3 | artifactId: "mywar"
4 | description: "Test for incrementals"
5 | war:
6 | groupId: "org.jenkins-ci.main"
7 | artifactId: "jenkins-war"
8 | source:
9 | git: https://github.com/jenkinsci/jenkins.git
10 | version: 2.118
11 | plugins:
12 | - groupId: "org.jenkins-ci.plugins"
13 | artifactId: "buildtriggerbadge"
14 | source:
15 | version: 2.10-rc129.5fad9a56d6e9
16 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/incrementals/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean package
2 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/incrementals/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | io.jenkins.tools.war-packager.its
7 | incrementals
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 |
13 | ${project.artifactId}
14 |
15 |
16 | @project.groupId@
17 | @project.artifactId@
18 | @project.version@
19 |
20 |
21 | package
22 |
23 | custom-war
24 |
25 |
26 | config.yml
27 | 1.1-SNAPSHOT
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom-with-maven-info-source/Makefile:
--------------------------------------------------------------------------------
1 | # Just a Makefile for manual testing
2 | .PHONY: all
3 |
4 | ARTIFACT_ID = with-maven-info-source-input-it
5 | VERSION = 256.0-SNAPSHOT
6 |
7 | all: clean build
8 |
9 | clean:
10 | rm -rf tmp
11 |
12 | build: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
13 |
14 | tmp/output/target/${ARTIFACT_ID}-${VERSION}.war:
15 | java \
16 | -jar $(shell ls ../../../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar) \
17 | -configPath config.yml -version ${VERSION}
18 |
19 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom-with-maven-info-source/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | systemMessage: "Custom War Packager - Demo of Configuration-as-Code plugin"
3 |
4 | crumbIssuer:
5 | standard:
6 | excludeClientIPFromCrumb: true
7 | agentProtocols:
8 | - "JNLP4-connect"
9 | - "Ping"
10 |
11 | securityRealm:
12 | local:
13 | allowsSignup: false
14 | users:
15 | - id: "admin"
16 | password: "admin"
17 | - id: "user"
18 | password: "user"
19 |
20 | # Ownership-based Security configuration sample.
21 | # It requires RoleStrategy and Ownership plugins to be installed.
22 | authorizationStrategy:
23 | roleBased:
24 | roles:
25 | global:
26 | - name: "admin"
27 | description: "Jenkins administrators"
28 | permissions:
29 | - "Overall/Administer"
30 | assignments:
31 | - "admin"
32 | - name: "readonly"
33 | description: "Read-only users"
34 | permissions:
35 | - "Overall/Read"
36 | - "Job/Read"
37 | - "Agent/Build"
38 | assignments:
39 | - "authenticated"
40 | items:
41 | - name: "@OwnerNoSid"
42 | description: "Primary Owners"
43 | pattern: ".*"
44 | permissions:
45 | - "Job/Configure"
46 | - "Job/Build"
47 | - "Job/Delete"
48 | assignments:
49 | - "authenticated"
50 | - name: "@CoOwnerNoSid"
51 | description: "Secondary Owners"
52 | pattern: ".*"
53 | permissions:
54 | - "Job/Configure"
55 | - "Job/Build"
56 | assignments:
57 | - "authenticated"
58 | agents:
59 | - name: "@OwnerNoSid"
60 | description: "Primary Owners"
61 | pattern: ".*"
62 | permissions:
63 | - "Agent/Configure"
64 | - "Agent/Build"
65 | - "Agent/Delete"
66 | - "Agent/Build"
67 | assignments:
68 | - "authenticated"
69 | - name: "@CoOwnerNoSid"
70 | description: "Secondary Owners"
71 | pattern: ".*"
72 | permissions:
73 | - "Agent/Connect"
74 | - "Agent/Build"
75 | assignments:
76 | - "authenticated"
77 |
78 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom-with-maven-info-source/config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.it.pom-with-maven-info-source"
3 | artifactId: "pom-with-maven-info-source"
4 | title: "CWP Integration Test for POM input with Maven Info input source"
5 | buildSettings:
6 | pom: pom.xml
7 | pomUseMavenPluginInfoProvider: true
8 | pomIgnoreRoot: true
9 | war:
10 | groupId: "org.jenkins-ci.main"
11 | artifactId: "jenkins-war"
12 | source:
13 | version: 2.176.1
14 | casc:
15 | - id: "casc"
16 | source:
17 | dir: casc.yml
18 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom-with-maven-info-source/invoker.properties:
--------------------------------------------------------------------------------
1 | # Test for JENKINS-55832
2 | invoker.goals=clean package
3 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom-with-maven-info-source/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | io.jenkins.tools.war-packager.its
7 | pom
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 |
13 |
14 | io.jenkins
15 | configuration-as-code
16 | 1.20
17 |
18 |
19 | org.jenkins-ci.plugins
20 | role-strategy
21 | 2.11
22 |
23 |
24 | org.jenkins-ci.plugins
25 | cloudbees-folder
26 | 6.6
27 |
28 |
29 |
30 |
31 | ${project.artifactId}
32 |
33 |
34 | @project.groupId@
35 | @project.artifactId@
36 | @project.version@
37 |
38 |
39 | package
40 |
41 | custom-war
42 |
43 |
44 | config.yml
45 | bom.yml
46 | aws
47 | 1.1-SNAPSHOT
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | repo.jenkins-ci.org
58 | https://repo.jenkins-ci.org/public/
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom/Makefile:
--------------------------------------------------------------------------------
1 | # Just a Makefile for manual testing
2 | .PHONY: all
3 |
4 | ARTIFACT_ID = pom-input-it
5 | VERSION = 2.176.1-pom-input-SNAPSHOT
6 |
7 | all: clean build
8 |
9 | clean:
10 | rm -rf tmp
11 |
12 | build: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
13 |
14 | tmp/output/target/${ARTIFACT_ID}-${VERSION}.war:
15 | java \
16 | -jar $(shell ls ../../../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar) \
17 | -configPath config.yml -version ${VERSION}
18 |
19 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | systemMessage: "Custom War Packager - Demo of Configuration-as-Code plugin"
3 |
4 | crumbIssuer:
5 | standard:
6 | excludeClientIPFromCrumb: true
7 | agentProtocols:
8 | - "JNLP4-connect"
9 | - "Ping"
10 |
11 | securityRealm:
12 | local:
13 | allowsSignup: false
14 | users:
15 | - id: "admin"
16 | password: "admin"
17 | - id: "user"
18 | password: "user"
19 |
20 | # Ownership-based Security configuration sample.
21 | # It requires RoleStrategy and Ownership plugins to be installed.
22 | authorizationStrategy:
23 | roleBased:
24 | roles:
25 | global:
26 | - name: "admin"
27 | description: "Jenkins administrators"
28 | permissions:
29 | - "Overall/Administer"
30 | assignments:
31 | - "admin"
32 | - name: "readonly"
33 | description: "Read-only users"
34 | permissions:
35 | - "Overall/Read"
36 | - "Job/Read"
37 | - "Agent/Build"
38 | assignments:
39 | - "authenticated"
40 | items:
41 | - name: "@OwnerNoSid"
42 | description: "Primary Owners"
43 | pattern: ".*"
44 | permissions:
45 | - "Job/Configure"
46 | - "Job/Build"
47 | - "Job/Delete"
48 | assignments:
49 | - "authenticated"
50 | - name: "@CoOwnerNoSid"
51 | description: "Secondary Owners"
52 | pattern: ".*"
53 | permissions:
54 | - "Job/Configure"
55 | - "Job/Build"
56 | assignments:
57 | - "authenticated"
58 | agents:
59 | - name: "@OwnerNoSid"
60 | description: "Primary Owners"
61 | pattern: ".*"
62 | permissions:
63 | - "Agent/Configure"
64 | - "Agent/Build"
65 | - "Agent/Delete"
66 | - "Agent/Build"
67 | assignments:
68 | - "authenticated"
69 | - name: "@CoOwnerNoSid"
70 | description: "Secondary Owners"
71 | pattern: ".*"
72 | permissions:
73 | - "Agent/Connect"
74 | - "Agent/Build"
75 | assignments:
76 | - "authenticated"
77 |
78 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom/config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.it.pom-input"
3 | artifactId: "cwp-pom-input-it"
4 | title: "CWP Integration Test for POM input and JENKINS-56444"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.176.1"
8 | tag: "jenkins-experimental/custom-war-packager-casc-demo"
9 | build: false
10 | pom: pom.xml
11 | pomIgnoreRoot: true
12 | war:
13 | groupId: "org.jenkins-ci.main"
14 | artifactId: "jenkins-war"
15 | source:
16 | version: 2.176.1
17 | casc:
18 | - id: "casc"
19 | source:
20 | dir: casc.yml
21 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom/invoker.properties:
--------------------------------------------------------------------------------
1 | # Test for JENKINS-55832
2 | invoker.goals=clean package
3 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/pom/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | io.jenkins.tools.war-packager.its
7 | pom
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 |
13 |
14 | io.jenkins
15 | configuration-as-code
16 | 1.20
17 |
18 |
19 | org.jenkins-ci.plugins
20 | role-strategy
21 | 2.11
22 |
23 |
24 | org.jenkins-ci.plugins
25 | cloudbees-folder
26 | 6.6
27 |
28 |
29 |
30 |
31 | ${project.artifactId}
32 |
33 |
34 | @project.groupId@
35 | @project.artifactId@
36 | @project.version@
37 |
38 |
39 | package
40 |
41 | custom-war
42 |
43 |
44 | config.yml
45 | bom.yml
46 | aws
47 | 1.1-SNAPSHOT
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | repo.jenkins-ci.org
58 | https://repo.jenkins-ci.org/public/
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/spotcheck/invoker.properties:
--------------------------------------------------------------------------------
1 | invoker.goals=clean package
2 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/spotcheck/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | io.jenkins.tools.war-packager.its
7 | spotcheck
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 |
13 | ${project.artifactId}
14 |
15 |
16 | @project.groupId@
17 | @project.artifactId@
18 | @project.version@
19 |
20 |
21 | package
22 |
23 | custom-war
24 |
25 |
26 | spotcheck.yml
27 | 1.1-SNAPSHOT
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/it/spotcheck/spotcheck.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.github.oleg-nenashev"
3 | artifactId: "mywar"
4 | description: "Just a WAR auto-generation-sample"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.107.3"
8 | war:
9 | groupId: "org.jenkins-ci.main"
10 | artifactId: "jenkins-war"
11 | source:
12 | version: 2.107.3
13 | plugins:
14 | - groupId: "org.jenkins-ci.plugins"
15 | artifactId: "matrix-project"
16 | source:
17 | version: 1.9
18 | - groupId: "org.jenkins-ci.plugins"
19 | artifactId: "durable-task"
20 | source:
21 | git: https://github.com/jenkinsci/durable-task-plugin.git
22 | commit: d6258dd63384de5ec261e7374028fd6f4a106dd0
23 |
--------------------------------------------------------------------------------
/custom-war-packager-maven-plugin/src/main/java/io/jenkins/tools/warpackager/mavenplugin/PackageMojo.java:
--------------------------------------------------------------------------------
1 | package io.jenkins.tools.warpackager.mavenplugin;
2 |
3 | import io.jenkins.tools.warpackager.lib.config.Config;
4 | import org.apache.maven.plugin.MojoExecutionException;
5 | import org.apache.maven.plugin.MojoFailureException;
6 | import org.apache.maven.plugins.annotations.Component;
7 | import org.apache.maven.plugins.annotations.Mojo;
8 | import org.apache.maven.project.MavenProject;
9 | import org.apache.maven.project.MavenProjectHelper;
10 |
11 | import java.io.File;
12 |
13 | import static org.apache.maven.plugins.annotations.LifecyclePhase.*;
14 | import static org.apache.maven.plugins.annotations.ResolutionScope.*;
15 |
16 | //TODO: There is a serious correlation with Maven HPI's Plugin "custom-war" step. This step is actually used inside via Maven-in-Maven. May be reworked later.
17 | /**
18 | * Mojo wrapper for {@link io.jenkins.tools.warpackager.lib.impl.Builder}.
19 | * @author Oleg Nenashev
20 | * @since TODO
21 | */
22 | @Mojo(name="custom-war", defaultPhase = PACKAGE, requiresDependencyResolution = RUNTIME)
23 | public class PackageMojo extends BuildMojo {
24 |
25 | @Component
26 | protected MavenProject project;
27 |
28 | @Component
29 | protected MavenProjectHelper projectHelper;
30 |
31 | @Override
32 | public void execute() throws MojoExecutionException, MojoFailureException {
33 | File buildDir = new File(project.getBuild().getDirectory(), "custom-war-packager-maven-plugin");
34 | Config cfg = getConfigOrFail();
35 |
36 | build(cfg, buildDir);
37 |
38 | projectHelper.attachArtifact(project, "war", cfg.getOutputWar());
39 | projectHelper.attachArtifact(project, "yml", "bom", cfg.getOutputBOM());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/demo/all-latest-core-maven/README.md:
--------------------------------------------------------------------------------
1 | Jenkins WAR Packager Demo. All-latest core (with Maven)
2 | ===
3 |
4 | This demo builds a Jenkins WAR which includes...
5 |
6 | * Master branch of the Jenkins core
7 | * Latest versions of Stapler, Remoting and XStream
8 | * Latest versions of some modules (full list - TODO)
9 | * Some agent installer modules have obsolete tooling, they need to be updated before inclusion
10 | * Latest version of Lib Task Reactor
11 |
12 | The demo is similar to [All-latest core](../all-latest-core) demo, but it runs in Maven.
13 |
14 | Limitations:
15 |
16 | * Only component JARs are updated, the builder does not update dependencies
17 | * WAR Packager is able to replace/add libs to WEB-INF/lib only, components
18 | like Extras Executable War cannot be updated right now
19 |
20 |
21 | ### Usage
22 |
23 | To build the demo just run the `mvn clean package` command.
24 | It will produce a `target/custom-war-packager-maven-plugin/output/target/jenkins-all-latest-1.1-SNAPSHOT.war` file.
25 | You can run this file as a common Jenkins WAR file.
26 |
--------------------------------------------------------------------------------
/demo/all-latest-core-maven/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | io.jenkins.tools.custom-war-packager.demo
7 | jenkins-all-latest-maven
8 | 1.0-SNAPSHOT
9 |
10 | pom
11 |
12 |
13 |
14 |
15 | io.jenkins.tools.custom-war-packager
16 | custom-war-packager-maven-plugin
17 | 0.1-alpha-2
18 |
19 |
20 | package
21 |
22 | custom-war
23 |
24 |
25 | ../all-latest-core/packager-config.yml
26 | 1.1-SNAPSHOT
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | repo.jenkins-ci.org
37 | https://repo.jenkins-ci.org/public/
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/demo/all-latest-core-maven/run.sh:
--------------------------------------------------------------------------------
1 | JENKINS_HOME=$(pwd)/work java -jar target/custom-war-packager-maven-plugin/output/target/jenkins-all-latest-1.1-SNAPSHOT.war --httpPort=8080 --prefix=/jenkins
2 |
3 |
--------------------------------------------------------------------------------
/demo/all-latest-core/README.md:
--------------------------------------------------------------------------------
1 | Jenkins WAR Packager Demo. All-latest core
2 | ===
3 |
4 | This demo builds a Jenkins WAR which includes...
5 |
6 | * Master branch of the Jenkins core
7 | * Latest versions of Stapler, Remoting and XStream
8 | * Latest versions of some modules (full list - TODO)
9 | * Some agent installer modules have obsolete tooling, they need to be updated before inclusion
10 | * Latest version of Lib Task Reactor
11 | * Docker Packaging for the build
12 |
13 | Limitations:
14 |
15 | * Only component JARs are updated, the builder does not update dependencies
16 | * WAR Packager is able to replace/add libs to WEB-INF/lib only, components
17 | like Extras Executable War cannot be updated right now
18 |
19 |
20 | ### Usage
21 |
22 | To build the demo just run the `sh build.sh` command.
23 | It will produce a `tmp/output/target/jenkins-all-latest-1.0-SNAPSHOT.war` file.
24 | You can run this file as a common Jenkins WAR file.
25 |
--------------------------------------------------------------------------------
/demo/all-latest-core/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | CLI_JAR=$(ls ../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar)
3 | java -jar ${CLI_JAR} -configPath packager-config.yml
4 |
5 |
--------------------------------------------------------------------------------
/demo/all-latest-core/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "jenkins-all-latest"
4 | vendor: "Jenkins project"
5 | title: "Jenkins WAR - all latest"
6 | description: "Just a Jenkins WAR, which includes all latest libs from master branches"
7 | buildSettings:
8 | docker:
9 | base: "jenkins/jenkins:2.107.3"
10 | war:
11 | groupId: "org.jenkins-ci.main"
12 | artifactId: "jenkins-war"
13 | source:
14 | git: https://github.com/jenkinsci/jenkins
15 | #TODO: replace by core components line in (/demo/stapler)
16 | # https://issues.jenkins-ci.org/browse/JENKINS-52880
17 | # You can add new libraries or replace existing ones
18 | #TODO: this thing demonstrates that it is a bad idea to include modules in such WAY. BOMs should be used instead
19 | libPatches:
20 | - groupId: "org.jenkins-ci"
21 | artifactId: "task-reactor"
22 | source:
23 | git: https://github.com/jenkinsci/lib-task-reactor.git
24 | - groupId: "org.jenkins-ci.main"
25 | artifactId: "remoting"
26 | source:
27 | git: https://github.com/jenkinsci/remoting.git
28 | # XStream Repo has corrupted versioning, it cannot be packaged and bundled properly
29 | # - groupId: "com.thoughtworks.xstream"
30 | # artifactId: "xstream"
31 | # source:
32 | # git: https://github.com/jenkinsci/xstream.git
33 | - groupId: "org.kohsuke.stapler"
34 | artifactId: "stapler"
35 | source:
36 | git: https://github.com/stapler/stapler.git
37 | - groupId: "org.kohsuke.stapler"
38 | artifactId: "stapler-groovy"
39 | source:
40 | git: https://github.com/stapler/stapler.git
41 | - groupId: "org.kohsuke.stapler"
42 | artifactId: "stapler-jelly"
43 | source:
44 | git: https://github.com/stapler/stapler.git
45 | - groupId: "org.kohsuke.stapler"
46 | artifactId: "stapler-jrebel"
47 | source:
48 | git: https://github.com/stapler/stapler.git
49 | - groupId: "org.jenkins-ci"
50 | artifactId: "bytecode-compatibility-transformer"
51 | source:
52 | git: https://github.com/jenkinsci/bytecode-compatibility-transformer.git
53 | - groupId: "org.kohsuke"
54 | artifactId: "asm6"
55 | source:
56 | version: 6.0_BETA
57 | # TODO: this one is bad idea, because it may require higher SSHD version (which we do not bump).
58 | # TODO: dependency resolution in WAR patcher?
59 | - groupId: "org.jenkins-ci.modules"
60 | artifactId: "sshd"
61 | source:
62 | git: https://github.com/jenkinsci/sshd-module.git
63 | # TODO: Enable once master branch is fixed
64 | # - groupId: "org.jenkins-ci.modules"
65 | # artifactId: "instance-identity"
66 | # source:
67 | # git: https://github.com/jenkinsci/instance-identity-module.git
68 | - groupId: "org.jenkins-ci.modules"
69 | artifactId: "slave-installer"
70 | source:
71 | git: https://github.com/jenkinsci/slave-installer-module.git
72 | - groupId: "org.jenkins-ci.modules"
73 | artifactId: "windows-slave-installer"
74 | source:
75 | git: https://github.com/jenkinsci/windows-slave-installer-module.git
76 | libExcludes:
77 | - groupId: "org.kohsuke"
78 | artifactId: "asm5"
79 | systemProperties: {
80 | jenkins.model.Jenkins.slaveAgentPort: "50000",
81 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
82 |
83 | # TODO: Support System Groovy Scripts Bundling
84 |
85 |
--------------------------------------------------------------------------------
/demo/all-latest-core/run.sh:
--------------------------------------------------------------------------------
1 | JENKINS_HOME=$(pwd)/work java -jar tmp/output/target/jenkins-all-latest-1.0-SNAPSHOT.war --httpPort=8080 --prefix=/jenkins
2 |
3 |
--------------------------------------------------------------------------------
/demo/artifact-manager-s3-pom/Makefile:
--------------------------------------------------------------------------------
1 | # Just a Makefile for manual testing
2 | .PHONY: all
3 |
4 | ARTIFACT_ID = pom-input-demo
5 | VERSION = 2.121.1-pom-input-SNAPSHOT
6 |
7 | all: clean build
8 |
9 | clean:
10 | rm -rf tmp
11 |
12 | build: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
13 |
14 | tmp/output/target/${ARTIFACT_ID}-${VERSION}.war:
15 | java \
16 | -jar $(shell ls ../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar) \
17 | -configPath packager-config.yml -version ${VERSION}
18 |
19 | run: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
20 | docker run --rm \
21 | -p 8080:8080 \
22 | jenkins-experimental/demo-pom-input
23 |
--------------------------------------------------------------------------------
/demo/artifact-manager-s3-pom/README.md:
--------------------------------------------------------------------------------
1 | Demo with POM input
2 | ===================
3 |
4 | This demo demonstrates packaging of Jenkins war and Docker image
5 | while using `pom.xml` as a input source for plugins and the Jenkins core definition.
6 |
7 | For a more advanced demo of pom.xml inputs see
8 | [ci.jenkins.io-runner](https://github.com/jenkinsci/ci.jenkins.io-runner/).
9 |
--------------------------------------------------------------------------------
/demo/artifact-manager-s3-pom/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.176.1"
8 | tag: "jenkins-experimental/demo-pom-input"
9 | build: true
10 | pom: pom.xml
11 | pomIgnoreRoot: true
12 | pomIncludeWar: true
13 |
--------------------------------------------------------------------------------
/demo/casc/Makefile:
--------------------------------------------------------------------------------
1 | # Just a Makefile for manual testing
2 | .PHONY: all
3 |
4 | ARTIFACT_ID = jenkins-casc-demo
5 | VERSION = 256.0-test
6 |
7 | all: clean build
8 |
9 | clean:
10 | rm -rf tmp
11 |
12 | build: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
13 |
14 | tmp/output/target/${ARTIFACT_ID}-${VERSION}.war:
15 | java \
16 | -jar $(shell ls ../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar) \
17 | -configPath packager-config.yml -version ${VERSION}
18 |
19 | run: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
20 | docker run --rm \
21 | -p 8080:8080 \
22 | jenkins-experimental/custom-war-packager-casc-demo
23 |
24 | pct: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
25 | docker run --rm \
26 | -v ${HOME}/.m2:/root/.m2 \
27 | -v $(shell pwd)/pct_out:/pct/out \
28 | -v $(shell pwd)/pct_tmp:/pct/tmp \
29 | -v $(shell pwd)/tmp/output/target/${ARTIFACT_ID}-${VERSION}.war:/pct/jenkins.war:ro \
30 | -e ARTIFACT_ID=role-strategy \
31 | -e INSTALL_BUNDLED_SNAPSHOTS=true \
32 | jenkins/pct \
33 | -mavenProperties jenkins-test-harness.version=2.38:jth.jenkins-war.path=/pct/jenkins.war
34 |
35 |
--------------------------------------------------------------------------------
/demo/casc/README.md:
--------------------------------------------------------------------------------
1 | Custom WAR Packager. Configuration-as-Code demo
2 | ===
3 |
4 | This demo demonstrates usage of Configuration-as-Code plugin together
5 | with Jenkins Custom WAR Packager.
6 |
7 | Use the provided Makefile in order to build (`make clean build`)
8 | and run (`make run`) the demo.
9 | The root Custom WAR Packager project should be built first before running.
10 |
11 |
12 |
--------------------------------------------------------------------------------
/demo/casc/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | systemMessage: "Custom War Packager - Demo of Configuration-as-Code plugin"
3 |
4 | crumbIssuer:
5 | standard:
6 | excludeClientIPFromCrumb: true
7 | agentProtocols:
8 | - "JNLP4-connect"
9 | - "Ping"
10 |
11 | securityRealm:
12 | local:
13 | allowsSignup: false
14 | users:
15 | - id: "admin"
16 | password: "admin"
17 | - id: "user"
18 | password: "user"
19 |
20 | # Ownership-based Security configuration sample.
21 | # It requires RoleStrategy and Ownership plugins to be installed.
22 | authorizationStrategy:
23 | roleBased:
24 | roles:
25 | global:
26 | - name: "admin"
27 | description: "Jenkins administrators"
28 | permissions:
29 | - "Overall/Administer"
30 | assignments:
31 | - "admin"
32 | - name: "readonly"
33 | description: "Read-only users"
34 | permissions:
35 | - "Overall/Read"
36 | - "Job/Read"
37 | - "Agent/Build"
38 | assignments:
39 | - "authenticated"
40 | items:
41 | - name: "@OwnerNoSid"
42 | description: "Primary Owners"
43 | pattern: ".*"
44 | permissions:
45 | - "Job/Configure"
46 | - "Job/Build"
47 | - "Job/Delete"
48 | assignments:
49 | - "authenticated"
50 | - name: "@CoOwnerNoSid"
51 | description: "Secondary Owners"
52 | pattern: ".*"
53 | permissions:
54 | - "Job/Configure"
55 | - "Job/Build"
56 | assignments:
57 | - "authenticated"
58 | agents:
59 | - name: "@OwnerNoSid"
60 | description: "Primary Owners"
61 | pattern: ".*"
62 | permissions:
63 | - "Agent/Configure"
64 | - "Agent/Build"
65 | - "Agent/Delete"
66 | - "Agent/Build"
67 | assignments:
68 | - "authenticated"
69 | - name: "@CoOwnerNoSid"
70 | description: "Secondary Owners"
71 | pattern: ".*"
72 | permissions:
73 | - "Agent/Connect"
74 | - "Agent/Build"
75 | assignments:
76 | - "authenticated"
77 |
78 |
--------------------------------------------------------------------------------
/demo/casc/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo.casc"
3 | artifactId: "jenkins-casc-demo"
4 | vendor: "Jenkins project"
5 | title: "Configuration-as-Code demo"
6 | description: "Configuration-as-Code demo, produced by Custom WAR Packager"
7 | buildSettings:
8 | docker:
9 | base: "jenkins/jenkins:2.138.2"
10 | tag: "jenkins-experimental/custom-war-packager-casc-demo"
11 | build: true
12 | war:
13 | groupId: "org.jenkins-ci.main"
14 | artifactId: "jenkins-war"
15 | source:
16 | version: 2.138.2
17 | plugins:
18 | - groupId: "io.jenkins"
19 | artifactId: "configuration-as-code"
20 | source:
21 | version: 1.1
22 | - groupId: "io.jenkins.configuration-as-code"
23 | artifactId: "configuration-as-code-support"
24 | source:
25 | version: 1.1
26 | - groupId: "org.jenkins-ci.plugins"
27 | artifactId: "role-strategy"
28 | source:
29 | version: "2.8.1"
30 | - groupId: "org.jenkins-ci.plugins"
31 | artifactId: "matrix-auth"
32 | source:
33 | version: "2.3"
34 | - groupId: "org.jenkins-ci.plugins"
35 | artifactId: "cloudbees-folder"
36 | source:
37 | version: "6.6"
38 | systemProperties:
39 | jenkins.install.runSetupWizard: "false"
40 | jenkins.model.Jenkins.slaveAgentPort: "50000"
41 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"
42 | casc:
43 | - id: "casc"
44 | source:
45 | dir: casc.yml
46 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/Makefile:
--------------------------------------------------------------------------------
1 | # Just a Makefile for manual testing
2 | .PHONY: all
3 |
4 | ARTIFACT_ID = jenkins-external-task-logging-elk-demo
5 | VERSION = 2.121.1-elk-SNAPSHOT
6 |
7 | all: clean build
8 |
9 | clean:
10 | rm -rf tmp
11 |
12 | build: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
13 |
14 | tmp/output/target/${ARTIFACT_ID}-${VERSION}.war:
15 | java \
16 | -jar $(shell ls ../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar) \
17 | -configPath packager-config.yml -version ${VERSION}
18 |
19 | run: tmp/output/target/${ARTIFACT_ID}-${VERSION}.war
20 | docker-compose rm -fv
21 | docker-compose up --build --force-recreate jenkins elk
22 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/README.md:
--------------------------------------------------------------------------------
1 | External Task Logging to Elasticsearch Demo
2 | ===
3 |
4 | This demo packages Jenkins WAR for External Task Logging to Elasticsearch with help of Logstash plugin.
5 |
6 | This demo includes [Logstash Plugin PR#18](https://github.com/jenkinsci/logstash-plugin/pull/18) and
7 | all its upstream dependencies.
8 | It also bundles auto-configuration System Groovy scripts, so that the WAR file starts
9 | up with pre-configured Logstash plugin settings and some other configs.
10 |
11 | Features of the demo:
12 |
13 | * Pipeline jobs logging goes to Elasticsearch
14 | * When tasks are executed on agents, the logs get posted to Elasticsearch directly
15 | without passing though the master and causing scalability issues
16 | * Pipeline jobs override standard Log actions in the Jenkins core, so the
17 | underlying implementation is transparent to users
18 | * Secrets are escaped in stored/displayed logs when running on master and agents.
19 | * Console annotations work as they work for common Jenkins instances
20 | * Log blocks are collapsible in the _Console_ screen
21 | * Origin container ID of every message is visible in Kibana (if you have set that up) via sender field
22 |
23 | The demo can be run in Docker Compose,
24 | ELK stack is provided by the [sebp/elk](https://hub.docker.com/r/sebp/elk/) image in this case.
25 |
26 | ## Prerequisites
27 |
28 | * Docker and Docker Compose are installed
29 |
30 | ## Building demo
31 |
32 | To build the demo...
33 |
34 | 1. Go to the repository root, run `mvn clean package` to build Jenkins Custom WAR Packager
35 | 2. Change directory to the demo root
36 | 3. Run `make build`
37 |
38 | First build may take a while, because the packager will need to checkout and build
39 | many repositories.
40 |
41 | ## Running demo
42 |
43 | 1. Run `make run`. It will spin up the demo with predefined environment.
44 | Jenkins will be available on the port 8080, credentials: `admin/admin`
45 | 2. If you want to run demo jobs on the agent,
46 | also run `docker-compose up agent` in a separate terminal window
47 | 3. In order to access the instance, use the "admin/admin" credentials.
48 | 4. Run one of the demo jobs.
49 | 5. Browse logs
50 | * Classic Log action queries data from Elasticsearch
51 | * There is a _Log (Kibana)_ action in runs, which shows Kibana.
52 | * In order to see Kibana logs, you will need to configure the default index in the
53 | embedded page once Jenkins starts up. Use `logstash/` as a default index and
54 | `@timestamp` as data source
55 |
56 | ## Manual run
57 |
58 | This guideline allows to run the demo locally.
59 | Only Logstash will be preconfigured.
60 |
61 | 1. Run `docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -it --name elk sebp/elk:es241_l240_k461`
62 | to start the Docker container to to expose ports
63 | 2. Run Jenkins using `JENKINS_HOME=$(pwd)/work java -jar tmp/output/target/external-task-logging-elk-2.107.3-elk-SNAPSHOT.war --httpPort=8080 --prefix=/jenkins`
64 | (or just `run run.sh`).
65 | * If needed, the demo can be configured by setting system properties
66 | * `elasticsearch.host` - host, defaults to `http://elk`
67 | * `elasticsearch.port` - Elasticsearch port, defaults to `9200`
68 | * `logstash.key` - Path to the root index/key for logging, defaults to `/logstash/logs`
69 | * `elasticsearch.username` and `elasticsearch.password` -
70 | 3. Pass through the installation Wizard
71 | 4. Create a Pipeline job with some logging (e.g. `echo` commands), run it
72 | 5. Browse logs (see above)
73 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | services:
4 | elk:
5 | image: sebp/elk:es241_l240_k461
6 | container_name: elk
7 | ports:
8 | - "5601:5601" # Kibana
9 | - "9200:9200" # Elasticsearch
10 | - "5044:5044" # Logstash
11 | expose:
12 | - "5601"
13 | - "9200"
14 | - "5044"
15 | jenkins:
16 | image: jenkins/demo-external-task-logging-elk:latest
17 | container_name: jenkins
18 | links:
19 | - elk
20 | environment:
21 | - JAVA_OPTS=-Dio.jenkins.demo.external-task-logging-elk.enabled=true -Djenkins.install.runSetupWizard=false
22 | ports:
23 | - "8080:8080"
24 | - "9000:9000"
25 | expose:
26 | - "8080"
27 | - "9000"
28 | agent:
29 | image: cloudbees/jnlp-slave-with-java-build-tools:2.2.0
30 | links:
31 | - elk
32 | - jenkins
33 | # TODO there is no -noreconnect yet this does not work when first started; you need to relaunch it; work around with wait-for-it: https://docs.docker.com/compose/startup-order/
34 | command: -url http://jenkins:8080/ f9bf0c290371481814f8bc235e3c53736ea9cd9f11b466b76ad794b91cb57a0b -workDir "/home/jenkins" agent
35 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "jenkins-external-task-logging-elk-demo"
4 | vendor: "Jenkins project"
5 | title: "Jenkins External Task Logging demo for Elasticsearch"
6 | description: "Jenkins External Task Logging demo for Elasticsearch, packaged as a single WAR file. It automatically configures logging on startup"
7 | buildSettings:
8 | docker:
9 | base: "jenkins/jenkins:2.121.1"
10 | tag: "jenkins/demo-external-task-logging-elk"
11 | build: true
12 | war:
13 | groupId: "org.jenkins-ci.main"
14 | artifactId: "jenkins-war"
15 | source:
16 | version: 2.121.1
17 | plugins:
18 | - groupId: "org.jenkins-ci.plugins"
19 | artifactId: "structs"
20 | source:
21 | version: 1.14
22 | - groupId: "org.jenkins-ci.plugins"
23 | artifactId: "scm-api"
24 | source:
25 | version: 2.2.7
26 | - groupId: "org.jenkins-ci.plugins.workflow"
27 | artifactId: "workflow-aggregator"
28 | source:
29 | version: 2.5
30 | - groupId: "org.jenkins-ci.plugins"
31 | artifactId: "durable-task"
32 | source:
33 | git: https://github.com/jglick/durable-task-plugin.git
34 | # https://github.com/jenkinsci/durable-task-plugin/pull/62
35 | # branch: watch-plus-UTF-8-JENKINS-31096
36 | commit: e219d474cdd656ae9296314ada48605d3c87ea1c
37 | - groupId: "org.jenkins-ci.plugins.workflow"
38 | artifactId: "workflow-api"
39 | source:
40 | git: https://github.com/jglick/workflow-api-plugin.git
41 | # https://github.com/jenkinsci/workflow-api-plugin/pull/67
42 | # branch: logs-JENKINS-38381
43 | commit: 834dce0d24cefcd00f70c223d2b438dc3ec986b2
44 | build:
45 | buildOriginalVersion: true
46 | - groupId: "org.jenkins-ci.plugins.workflow"
47 | artifactId: "workflow-step-api"
48 | source:
49 | version: 2.15
50 | - groupId: "org.jenkins-ci.plugins.workflow"
51 | artifactId: "workflow-support"
52 | source:
53 | git: https://github.com/jenkinsci/workflow-support-plugin.git
54 | commit: cd70bcc4c20940fc8b54e12ded4d781a19ac0485
55 | build:
56 | buildOriginalVersion: true
57 | - groupId: "org.jenkins-ci.plugins.workflow"
58 | artifactId: "workflow-job"
59 | source:
60 | git: https://github.com/jenkinsci/workflow-job-plugin.git
61 | commit: 18d78f305a4526af9cdf3a7b68eb9caf97c7cfbc
62 | build:
63 | buildOriginalVersion: true
64 | - groupId: "org.jenkins-ci.plugins.workflow"
65 | artifactId: "workflow-durable-task-step"
66 | source:
67 | git: https://github.com/jenkinsci/workflow-durable-task-step-plugin.git
68 | commit: 6c424e059bba90fc94a9c1e87dc9c4a324bfef26
69 | build:
70 | buildOriginalVersion: true
71 | - groupId: "org.jenkins-ci.plugins"
72 | artifactId: "logstash"
73 | source:
74 | git: https://github.com/jglick/logstash-plugin.git
75 | # https://github.com/jenkinsci/logstash-plugin/pull/18
76 | # branch: logs-JENKINS-38381
77 | commit: 3b112333115b6a3ee003a8f03c0f0c907b6c8881
78 | # Security warnings
79 | - groupId: "org.jenkins-ci.plugins"
80 | artifactId: "junit"
81 | source:
82 | version: 1.24
83 | - groupId: "org.jenkins-ci.plugins"
84 | artifactId: "mailer"
85 | source:
86 | version: 1.21
87 | - groupId: "org.jenkins-ci.plugins"
88 | artifactId: "git-client"
89 | source:
90 | version: 2.7.2
91 | - groupId: "org.jenkins-ci.plugins"
92 | artifactId: "credentials-binding"
93 | source:
94 | version: 1.16
95 | - groupId: "org.jenkins-ci.plugins"
96 | artifactId: "docker-commons"
97 | source:
98 | version: 1.13
99 | systemProperties: {
100 | jenkins.model.Jenkins.slaveAgentPort: "9000",
101 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
102 | groovyHooks:
103 | - type: "init"
104 | id: "initScripts"
105 | source:
106 | dir: src/main/groovy
107 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/src/main/groovy/1_System.groovy:
--------------------------------------------------------------------------------
1 | import hudson.security.csrf.DefaultCrumbIssuer
2 | import hudson.model.*
3 | import hudson.security.FullControlOnceLoggedInAuthorizationStrategy
4 | import hudson.security.HudsonPrivateSecurityRealm
5 | import hudson.util.Secret
6 | import jenkins.model.Jenkins
7 | import jenkins.model.JenkinsLocationConfiguration
8 | import jenkins.CLI
9 | import jenkins.security.s2m.AdminWhitelistRule
10 | import org.kohsuke.stapler.StaplerProxy
11 |
12 | import com.cloudbees.plugins.credentials.CredentialsProvider
13 | import com.cloudbees.plugins.credentials.CredentialsScope
14 | import com.cloudbees.plugins.credentials.domains.Domain
15 | import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl
16 |
17 | //TODO: Migrate to JCasC once it supports disabling via system property
18 |
19 | if (!Boolean.getBoolean("io.jenkins.demo.external-task-logging-elk.enabled")) {
20 | // Production mode, we do not configure the system
21 | return
22 | }
23 |
24 | println("-- System configuration")
25 |
26 | println("--- Installing the Security Realm")
27 | def securityRealm = new HudsonPrivateSecurityRealm(false)
28 | User user = securityRealm.createAccount("user", "user")
29 | user.setFullName("User")
30 | User admin = securityRealm.createAccount("admin", "admin")
31 | admin.setFullName("Admin")
32 | Jenkins.instance.setSecurityRealm(securityRealm)
33 |
34 | println("---Installing the demo Authorization strategy")
35 | Jenkins.instance.authorizationStrategy = new FullControlOnceLoggedInAuthorizationStrategy()
36 |
37 | println("--- Configuring Remoting (JNLP4 only, no Remoting CLI)")
38 | CLI.get().enabled = false
39 | Jenkins.instance.agentProtocols = new HashSet(["JNLP4-connect"])
40 | Jenkins.instance.getExtensionList(StaplerProxy.class)
41 | .get(AdminWhitelistRule.class)
42 | .masterKillSwitch = false
43 |
44 | println("--- Checking the CSRF protection")
45 | if (Jenkins.instance.crumbIssuer == null) {
46 | println "CSRF protection is disabled, Enabling the default Crumb Issuer"
47 | Jenkins.instance.crumbIssuer = new DefaultCrumbIssuer(true)
48 | }
49 |
50 | println("--- Configuring Quiet Period")
51 | // We do not wait for anything, demo should be fast
52 | Jenkins.instance.quietPeriod = 0
53 |
54 | println("--- Configuring Email global settings")
55 | JenkinsLocationConfiguration.get().adminAddress = "admin@non.existent.email"
56 | // Mailer.descriptor().defaultSuffix = "@non.existent.email"
57 |
58 | println("--- Adding test credentials")
59 | def c = new StringCredentialsImpl(
60 | CredentialsScope.GLOBAL,
61 | "token",
62 | "Test token",
63 | Secret.fromString("SECRET_TOKEN_WHICH_SHOULD_NOD_BE_DISPLAYED")
64 | )
65 |
66 | CredentialsProvider.lookupStores(Jenkins.instance).each { it ->
67 | it.addCredentials(Domain.global(), c)
68 | }
69 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/src/main/groovy/2_Logstash.groovy:
--------------------------------------------------------------------------------
1 | import jenkins.plugins.logstash.LogstashInstallation
2 | import jenkins.plugins.logstash.LogstashConfiguration
3 | import jenkins.plugins.logstash.persistence.LogstashIndexerDao;
4 |
5 | println("--- Configuring Logstash")
6 | String logstashPort = System.getProperty("elasticsearch.port");
7 |
8 | def descriptor = LogstashInstallation.logstashDescriptor
9 | descriptor.@type = LogstashIndexerDao.IndexerType.ELASTICSEARCH
10 | descriptor.@host = System.getProperty("elasticsearch.host", "http://elk")
11 | descriptor.@port = logstashPort != null ? Integer.parseInt(logstashPort) : 9200
12 | descriptor.@username = System.getProperty("elasticsearch.username")
13 | descriptor.@password = System.getProperty("elasticsearch.password")
14 | descriptor.@key = System.getProperty("logstash.key", "/logstash/logs")
15 |
16 | // TODO: Replace by proper initialization once plugin API is fixed
17 | // Currently setIndexer() method does not change active indexer.
18 | LogstashConfiguration.instance.@dataMigrated = false
19 | LogstashConfiguration.instance.migrateData()
20 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/src/main/groovy/3_Agent.groovy:
--------------------------------------------------------------------------------
1 | import hudson.slaves.DumbSlave;
2 | import hudson.slaves.JNLPLauncher;
3 | import jenkins.model.Jenkins;
4 | import jenkins.slaves.JnlpSlaveAgentProtocol;
5 |
6 | import javax.crypto.spec.SecretKeySpec;
7 |
8 | println("-- Configuring the agent")
9 |
10 | // Hardcode secret so that Docker Compose can connect agents
11 | JnlpSlaveAgentProtocol.SLAVE_SECRET.@key = new SecretKeySpec(new byte[10], "HmacSHA256");
12 |
13 | // Register the agent
14 | def node = new DumbSlave("agent", "/home/jenkins", new JNLPLauncher(true));
15 | Jenkins.instance.addNode(node);
16 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/src/main/groovy/4_Jobs.groovy:
--------------------------------------------------------------------------------
1 | //TODO: Migrate to JCasC once it supports disabling via system property
2 | import jenkins.model.Jenkins
3 | import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition
4 | import org.jenkinsci.plugins.workflow.job.WorkflowJob
5 |
6 | if (!Boolean.getBoolean("io.jenkins.demo.external-task-logging-elk.enabled")) {
7 | // Production mode, we do not configure the system
8 | return
9 | }
10 |
11 | println("-- Creating Jobs")
12 | //TODO: Classes do not work here, so some copy-paste for now
13 |
14 | if(Jenkins.instance.getItem("Demo_master") == null) {
15 | WorkflowJob project1 = Jenkins.instance.createProject(WorkflowJob.class, "Demo_master")
16 | project1.definition = new CpsFlowDefinition(
17 | "node('master') {\n" +
18 | " sh \"ping -c 20 google.com\"\n" +
19 | "}",
20 | true // Sandbox
21 | )
22 | project1.save()
23 | }
24 |
25 | if(Jenkins.instance.getItem("Demo_agent") == null) {
26 | WorkflowJob project2 = Jenkins.instance.createProject(WorkflowJob.class, "Demo_agent")
27 | project2.definition = new CpsFlowDefinition(
28 | "node('agent') {\n" +
29 | " sh \"echo Hello, world!\"\n" +
30 | // TODO Current demo image does not have ping, ORLY (alpine)
31 | // " sh \"ping -c 20 google.com\"\n" +
32 | "}",
33 | true // Sandbox
34 | )
35 | project2.save()
36 | }
37 |
38 | if(Jenkins.instance.getItem("Demo_parallel") == null) {
39 | WorkflowJob project3 = Jenkins.instance.createProject(WorkflowJob.class, "Demo_parallel")
40 | project3.definition = new CpsFlowDefinition(
41 | "parallel local: {\n" +
42 | " node('master') {\n" +
43 | " sh 'for x in 0 1 2 3 4 5 6 7 8 9; do echo \$x; sleep 1; done'\n" +
44 | " }\n" +
45 | "}, remote: {\n" +
46 | " node('agent') {\n" +
47 | " withCredentials([string(credentialsId: 'token', variable: 'TOKEN')]) {\n" +
48 | " sh 'echo receiving \$TOKEN'\n" +
49 | " sh 'for x in 0 1 2 3 4 5 6 7 8 9; do echo \$x; sleep 1; done'\n" +
50 | " }\n" +
51 | " }\n" +
52 | "}",
53 | true // Sandbox
54 | )
55 | project3.save()
56 | }
57 |
--------------------------------------------------------------------------------
/demo/external-logging-elasticsearch/src/main/groovy/5_SaveToDisk.groovy:
--------------------------------------------------------------------------------
1 | import jenkins.model.Jenkins
2 |
3 | Jenkins.instance.save()
4 |
--------------------------------------------------------------------------------
/demo/jenkinsfile-runner/Makefile:
--------------------------------------------------------------------------------
1 | # Just a Makefile for manual testing
2 | .PHONY: all
3 |
4 | ARTIFACT_ID = jenkinsfile-runner-demo
5 | VERSION = 256.0-test
6 | CWP_VERSION = 1.3
7 |
8 | all: clean build
9 |
10 | clean:
11 | rm -rf tmp
12 |
13 | .build/cwp-cli-${CWP_VERSION}.jar:
14 | rm -rf .build
15 | mkdir -p .build
16 | wget -O .build/cwp-cli-${CWP_VERSION}.jar https://repo.jenkins-ci.org/releases/io/jenkins/tools/custom-war-packager/custom-war-packager-cli/${CWP_VERSION}/custom-war-packager-cli-${CWP_VERSION}-jar-with-dependencies.jar
17 |
18 | build: .build/cwp-cli-${CWP_VERSION}.jar
19 | java -jar .build/cwp-cli-${CWP_VERSION}.jar \
20 | -configPath packager-config.yml -version ${VERSION}
21 |
22 | build-devel:
23 | java -jar ../../custom-war-packager-cli/target/custom-war-packager-cli-*-SNAPSHOT-jar-with-dependencies.jar \
24 | -configPath packager-config.yml -version ${VERSION}
25 |
26 | build-devel-debug:
27 | java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 \
28 | -jar ../../custom-war-packager-cli/target/custom-war-packager-cli-*-SNAPSHOT-jar-with-dependencies.jar \
29 | -configPath packager-config.yml -version ${VERSION}
30 |
31 | run:
32 | docker run --rm -v $(shell pwd)/demo/Jenkinsfile:/workspace/Jenkinsfile \
33 | jenkins-experimental/cwp-jenkinsfile-runner-demo
34 |
--------------------------------------------------------------------------------
/demo/jenkinsfile-runner/README.md:
--------------------------------------------------------------------------------
1 | Custom WAR Packager. Jenkinsfile Builder demo
2 | ===
3 |
4 | This demo demonstrates building of Jenkinsfile Runner Docker images
5 | with Custom WAR Packager.
6 |
7 | To build the, run `make clean build`
8 |
9 | You can experiment with other `Jenkinsfile`s if needed.
10 | Once the Docker image is built, the demo Jenkinsfile Runner can be started simply as..
11 |
12 | docker run --rm -v $PWD/demo/Jenkinsfile:/workspace/Jenkinsfile jenkins-experimental/cwp-jenkinsfile-runner-demo
13 |
14 |
15 | or in Kubernetes
16 |
17 | kubectl create configmap jenkinsfile --from-file=demo/Jenkinsfile
18 | kubectl create -f demo/kubernetes.yaml
19 |
20 |
--------------------------------------------------------------------------------
/demo/jenkinsfile-runner/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | globalNodeProperties:
3 | - envVars:
4 | env:
5 | - key: SOME_CASC_ENV_VAR
6 | value: 'Hello from JCasC!'
7 |
--------------------------------------------------------------------------------
/demo/jenkinsfile-runner/demo/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline {
2 | agent any
3 | stages {
4 | stage('Build') {
5 | steps {
6 | echo 'Hello world!'
7 | echo "An environment variable configured via JCasC: ${env.SOME_CASC_ENV_VAR}"
8 | }
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/demo/jenkinsfile-runner/demo/kubernetes.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: batch/v1
2 | kind: Job
3 | metadata:
4 | name: jenkinsfile-runner
5 | spec:
6 | template:
7 | spec:
8 | containers:
9 | - name: jenkinsfile-runner
10 | image: jenkins-experimental/cwp-jenkinsfile-runner-demo
11 | volumeMounts:
12 | - name: jenkinsfile
13 | mountPath: /workspace
14 | volumes:
15 | - name: jenkinsfile
16 | configMap:
17 | name: jenkinsfile
18 | restartPolicy: Never
19 | backoffLimit: 1
20 |
--------------------------------------------------------------------------------
/demo/jenkinsfile-runner/init.groovy:
--------------------------------------------------------------------------------
1 | // Just a stub Groovy initialization hook
2 |
3 | println("-- System configuration by Groovy Hooks")
4 |
--------------------------------------------------------------------------------
/demo/jenkinsfile-runner/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins.jenkinsfile-runner"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | # Jenkinsfile Runner produces appassembler directory which is not a maven artifact
14 | #TODO: replace once Jenkinsfile Runner archives runner & CWP is updated
15 | noCache: true
16 | source:
17 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
18 | branch: 1.0-beta-14
19 | docker:
20 | base: "openjdk:8-jdk"
21 | tag: "jenkins-experimental/cwp-jenkinsfile-runner-demo"
22 | build: true
23 | war:
24 | groupId: "org.jenkins-ci.main"
25 | artifactId: "jenkins-war"
26 | source:
27 | version: "2.235.2"
28 | plugins:
29 | - groupId: "org.jenkins-ci.plugins.workflow"
30 | artifactId: "workflow-job"
31 | source:
32 | version: "2.39"
33 | - groupId: "org.jenkins-ci.plugins.workflow"
34 | artifactId: "workflow-cps"
35 | source:
36 | version: "2.81"
37 | - groupId: "org.jenkins-ci.plugins.workflow"
38 | artifactId: "workflow-api"
39 | source:
40 | version: "2.40"
41 | - groupId: "org.jenkins-ci.plugins.workflow"
42 | artifactId: "workflow-step-api"
43 | source:
44 | version: "2.22"
45 | - groupId: "org.jenkins-ci.plugins.workflow"
46 | artifactId: "workflow-support"
47 | source:
48 | version: "3.5"
49 | - groupId: "org.jenkins-ci.plugins"
50 | artifactId: "pipeline-utility-steps"
51 | source:
52 | version: "2.6.1"
53 | - groupId: "org.jenkins-ci.plugins"
54 | artifactId: "cloudbees-folder"
55 | source:
56 | version: "6.14"
57 | - groupId: "org.jenkins-ci.plugins"
58 | artifactId: "credentials"
59 | source:
60 | version: "2.3.12"
61 | - groupId: "org.jenkins-ci.plugins"
62 | artifactId: "structs"
63 | source:
64 | version: "1.20"
65 | - groupId: "org.jenkins-ci.plugins"
66 | artifactId: "scm-api"
67 | source:
68 | version: "2.6.3"
69 | - groupId: "org.jenkins-ci.plugins"
70 | artifactId: "ssh-credentials"
71 | source:
72 | version: "1.18.1"
73 | - groupId: "org.jenkins-ci.plugins"
74 | artifactId: "mailer"
75 | source:
76 | version: "1.32"
77 | - groupId: "org.jenkins-ci.plugins"
78 | artifactId: "credentials-binding"
79 | source:
80 | version: "1.23"
81 | - groupId: "io.jenkins"
82 | artifactId: "configuration-as-code"
83 | source:
84 | version: "1.41"
85 | systemProperties: {
86 | jenkins.model.Jenkins.slaveAgentPort: "50000",
87 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
88 | casc:
89 | - id: "jcasc"
90 | source:
91 | dir: casc.yml
92 | groovyHooks:
93 | - type: "init"
94 | id: "initScripts"
95 | source:
96 | dir: init.groovy
97 |
--------------------------------------------------------------------------------
/demo/multi-platform-images/README.md:
--------------------------------------------------------------------------------
1 | Jenkins WAR Packager Demo. Multi-platform Image
2 | ===
3 |
4 | This demo builds a Jenkins docker image which contains multi-platform.
5 |
6 | ### Usage
7 |
8 | To build the demo just run the `sh build.sh` command.
9 | It will produce a image `jenkins/multi-platform` which contains linux/amd64 and linux/arm64.
10 |
--------------------------------------------------------------------------------
/demo/multi-platform-images/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | CLI_JAR=$(ls ../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar)
3 | java -jar ${CLI_JAR} -configPath packager-config.yml
4 |
5 |
--------------------------------------------------------------------------------
/demo/multi-platform-images/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins-ci.main"
3 | artifactId: "jenkins-war"
4 | vendor: "Jenkins project"
5 | title: "Jenkins WAR - Multi-platform Image"
6 | description: "Bundles stapler "
7 | war:
8 | groupId: "org.jenkins-ci.main"
9 | artifactId: "jenkins-war"
10 | source:
11 | version: 2.249.1
12 | buildSettings:
13 | docker:
14 | base: "jenkins4eval/jenkins:2.249.1"
15 | tag: "jenkins/multi-platform"
16 | platform: linux/amd64,linux/arm64
17 | output: push
18 | buildx: true
19 | build: true
20 |
--------------------------------------------------------------------------------
/demo/stapler/README.md:
--------------------------------------------------------------------------------
1 | Jenkins WAR Packager Demo. Stapler
2 | ===
3 |
4 | This demo builds a Jenkins WAR which includes...
5 |
6 | * `master` version of stapler
7 |
8 |
9 | ### Usage
10 |
11 | To build the demo just run the `sh build.sh` command.
12 | It will produce a `tmp/output/target/jenkins-stapler-1.0-SNAPSHOT.war` file.
13 | You can run this file as a common Jenkins WAR file.
14 |
--------------------------------------------------------------------------------
/demo/stapler/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | CLI_JAR=$(ls ../../custom-war-packager-cli/target/custom-war-packager-cli-*-jar-with-dependencies.jar)
3 | java -jar ${CLI_JAR} -configPath packager-config.yml
4 |
5 |
--------------------------------------------------------------------------------
/demo/stapler/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins-ci.main"
3 | artifactId: "jenkins-war"
4 | vendor: "Jenkins project"
5 | title: "Jenkins WAR - Stapler Integration Tests"
6 | description: "Bundles stapler "
7 | war:
8 | groupId: "org.jenkins-ci.main"
9 | artifactId: "jenkins-war"
10 | source:
11 | git: "https://github.com/jenkinsci/jenkins"
12 | libraries:
13 | - property: "stapler.version"
14 | source:
15 | groupId: "org.kohsuke.stapler"
16 | artifactId: "stapler"
17 | source:
18 | git: "https://github.com/stapler/stapler.git"
19 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/Makefile:
--------------------------------------------------------------------------------
1 | # Just a Makefile for automatic testing
2 | .PHONY: all
3 |
4 | all: clean init test
5 |
6 | clean:
7 | rm -rf .jenkinsfile-runner-test-framework
8 | rm -rf cwp.jar
9 |
10 | init:
11 | git clone https://github.com/jenkinsci/jenkinsfile-runner-test-framework .jenkinsfile-runner-test-framework && cd .jenkinsfile-runner-test-framework && git checkout 4ed3c35650fe880345b77ee4776b29bd00944fb3
12 | rsync -avq --exclude-from='exclude-rsync.txt' $(shell pwd)/../ $(shell pwd)/.jenkinsfile-runner-test-framework/source
13 | $(MAKE) -C .jenkinsfile-runner-test-framework
14 |
15 | test:
16 | ./tests.sh
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/README.md:
--------------------------------------------------------------------------------
1 | # Integration tests for Custom WAR Packager and Jenkinsfile Runner
2 |
3 | ## Running the tests on macOS
4 | The version of shUnit2 we are using does not work with the default bash shell on macOS. In order to get the tests to run, we recommend upgrading your bash shell to a more modern version by following the instructions below.
5 |
6 | + Use [Homebrew](https://brew.sh/) to install the latest version of bash with the command `brew install bash`
7 | + To verify the installation, execute the command `which -a bash` This should list at least two entries, including `/bin/bash` and `/usr/local/bin/bash`
8 | + Change the first line of [tests.sh](https://github.com/jenkinsci/custom-war-packager/blob/master/tests.sh) from `#!/bin/bash` to `#!/usr/local/bin/bash`
9 |
10 | More information on updating your bash shell can be found here [Upgrading bash on macOs](https://itnext.io/upgrading-bash-on-macos-7138bd1066ba)
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/exclude-rsync.txt:
--------------------------------------------------------------------------------
1 | demo
2 | packaging
3 | jenkinsfile-runner-tests/.jenkinsfile-runner-test-framework
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 |
5 | io.jenkins.tools.custom-war-packager
6 | parent-pom
7 | 2.0-alpha-7-SNAPSHOT
8 |
9 |
10 | jenkinsfile-runner-tests
11 | Integration tests for Custom war Packager and Jenkinsfile Runner
12 |
13 |
14 |
15 | launch-test
16 |
17 |
18 | environment
19 | test
20 |
21 |
22 |
23 |
24 |
25 | org.codehaus.mojo
26 | exec-maven-plugin
27 | 3.0.0
28 |
29 |
30 | test
31 | test
32 |
33 | exec
34 |
35 |
36 | make
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_simple/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline {
2 | agent any
3 | stages {
4 | stage('Get System Message') {
5 | steps {
6 | script {
7 | def instance = Jenkins.get()
8 | def systemMesssage = instance.getSystemMessage()
9 | echo "Message: ${systemMesssage}"
10 | }
11 | }
12 | }
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_simple/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code Plugin\n\n"
3 | numExecutors: 5
4 | scmCheckoutRetryCount: 2
5 | mode: NORMAL
6 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_simple/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-7
17 | docker:
18 | base: "jenkins/jenkins:2.150.3"
19 | tag: "jenkins-experimental/jenkinsfile-runner-demo"
20 | build: false
21 | war:
22 | groupId: "org.jenkins-ci.main"
23 | artifactId: "jenkins-war"
24 | source:
25 | version: "2.150.3"
26 | plugins:
27 | - groupId: "org.jenkins-ci.plugins.workflow"
28 | artifactId: "workflow-job"
29 | source:
30 | version: "2.24"
31 | - groupId: "org.jenkins-ci.plugins.workflow"
32 | artifactId: "workflow-cps"
33 | source:
34 | version: "2.48"
35 | - groupId: "org.jenkins-ci.plugins.workflow"
36 | artifactId: "workflow-api"
37 | source:
38 | version: "2.27"
39 | - groupId: "org.jenkins-ci.plugins.workflow"
40 | artifactId: "workflow-step-api"
41 | source:
42 | version: "2.14"
43 | - groupId: "org.jenkins-ci.plugins"
44 | artifactId: "pipeline-utility-steps"
45 | source:
46 | version: "2.1.0"
47 | - groupId: "org.jenkins-ci.plugins"
48 | artifactId: "cloudbees-folder"
49 | source:
50 | version: "6.4"
51 | - groupId: "org.jenkins-ci.plugins"
52 | artifactId: "credentials"
53 | source:
54 | version: "2.1.11"
55 | - groupId: "org.jenkins-ci.plugins"
56 | artifactId: "structs"
57 | source:
58 | version: "1.14"
59 | - groupId: "org.jenkins-ci.plugins"
60 | artifactId: "scm-api"
61 | source:
62 | version: "2.2.6"
63 | - groupId: "org.jenkins-ci.plugins"
64 | artifactId: "ssh-credentials"
65 | source:
66 | version: "1.12"
67 | - groupId: "org.jenkins-ci.plugins"
68 | artifactId: "credentials-binding"
69 | source:
70 | version: "1.16"
71 | - groupId: "org.jenkins-ci.plugins"
72 | artifactId: "credentials-binding"
73 | source:
74 | version: "1.16"
75 | - groupId: "org.jenkins-ci.plugins.workflow"
76 | artifactId: "workflow-aggregator"
77 | source:
78 | version: "2.5"
79 | - groupId: "io.jenkins"
80 | artifactId: "configuration-as-code"
81 | source:
82 | version: "1.5"
83 | systemProperties: {
84 | jenkins.model.Jenkins.slaveAgentPort: "50000",
85 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
86 | casc:
87 | - id: "casc"
88 | source:
89 | dir: ./test_resources/test_cwp_casc_simple/casc.yml
90 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_with_pipeline_library/Jenkinsfile:
--------------------------------------------------------------------------------
1 | @Library('awesome-lib@master') _
2 |
3 | stage('Simple library test') {
4 | node {
5 | def trusted = infra.isTrusted()
6 | def onJenkinsInfra = infra.isRunningOnJenkinsInfra()
7 | echo "TRUSTED? " + trusted + " On Jenkins Infra? " + onJenkinsInfra
8 | }
9 | }
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_with_pipeline_library/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code Plugin\n\n"
3 | numExecutors: 5
4 | scmCheckoutRetryCount: 2
5 | mode: NORMAL
6 |
7 | unclassified:
8 | globalLibraries:
9 | libraries:
10 | - name: "awesome-lib"
11 | retriever:
12 | legacySCM:
13 | scm:
14 | git:
15 | branches:
16 | - name: "*/master"
17 | doGenerateSubmoduleConfigurations: false
18 | userRemoteConfigs:
19 | - url: "https://github.com/jenkins-infra/pipeline-library.git"
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_with_pipeline_library/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-7
17 | docker:
18 | base: "jenkins/jenkins:2.150.3"
19 | tag: "jenkins-experimental/jenkinsfile-runner-demo"
20 | build: false
21 | war:
22 | groupId: "org.jenkins-ci.main"
23 | artifactId: "jenkins-war"
24 | source:
25 | version: "2.150.3"
26 | plugins:
27 | - groupId: "org.jenkins-ci.plugins.workflow"
28 | artifactId: "workflow-job"
29 | source:
30 | version: "2.31"
31 | - groupId: "org.jenkins-ci.plugins.workflow"
32 | artifactId: "workflow-cps"
33 | source:
34 | version: "2.63"
35 | - groupId: "org.jenkins-ci.plugins.workflow"
36 | artifactId: "workflow-cps-global-lib"
37 | source:
38 | version: "2.13"
39 | - groupId: "org.jenkins-ci.plugins.workflow"
40 | artifactId: "workflow-api"
41 | source:
42 | version: "2.33"
43 | - groupId: "org.jenkins-ci.plugins.workflow"
44 | artifactId: "workflow-step-api"
45 | source:
46 | version: "2.19"
47 | - groupId: "org.jenkins-ci.plugins.workflow"
48 | artifactId: "workflow-support"
49 | source:
50 | version: "3.2"
51 | - groupId: "org.jenkins-ci.plugins"
52 | artifactId: "pipeline-utility-steps"
53 | source:
54 | version: "2.2.0"
55 | - groupId: "org.jenkins-ci.plugins"
56 | artifactId: "cloudbees-folder"
57 | source:
58 | version: "6.4"
59 | - groupId: "org.jenkins-ci.plugins"
60 | artifactId: "credentials"
61 | source:
62 | version: "2.1.18"
63 | - groupId: "org.jenkins-ci.plugins"
64 | artifactId: "structs"
65 | source:
66 | version: "1.17"
67 | - groupId: "org.jenkins-ci.plugins"
68 | artifactId: "scm-api"
69 | source:
70 | version: "2.3.0"
71 | - groupId: "org.jenkins-ci.plugins"
72 | artifactId: "ssh-credentials"
73 | source:
74 | version: "1.14"
75 | - groupId: "org.jenkins-ci.plugins"
76 | artifactId: "credentials-binding"
77 | source:
78 | version: "1.16"
79 | - groupId: "org.jenkins-ci.plugins"
80 | artifactId: "permissive-script-security"
81 | source:
82 | version: "0.3"
83 | - groupId: "org.jenkins-ci.plugins"
84 | artifactId: "git"
85 | source:
86 | version: "3.0.0"
87 | - groupId: "org.jenkins-ci.plugins.workflow"
88 | artifactId: "workflow-aggregator"
89 | source:
90 | version: "2.5"
91 | - groupId: "io.jenkins"
92 | artifactId: "configuration-as-code"
93 | source:
94 | version: "1.5"
95 | - groupId: "io.jenkins.configuration-as-code"
96 | artifactId: "configuration-as-code-support"
97 | source:
98 | version: "1.5"
99 | systemProperties: {
100 | jenkins.model.Jenkins.slaveAgentPort: "50000",
101 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
102 | casc:
103 | - id: "casc"
104 | source:
105 | dir: ./test_resources/test_cwp_casc_with_pipeline_library/casc.yml
106 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_with_tool/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline {
2 | agent any
3 | tools {
4 | maven 'maven'
5 | }
6 | stages {
7 | stage('install maven') {
8 | steps {
9 | //
10 | // FIXME see if we can updated casc.yml to install maven for us.
11 | //
12 | sh '''
13 | mkdir /var/jenkins_home/tools
14 | cd /var/jenkins_home/tools
15 | rm -rf apache-maven-3.3.3-bin*
16 | wget --no-verbose https://archive.apache.org/dist/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
17 | tar -xzf apache-maven-3.3.3-bin.tar.gz
18 | '''
19 | }
20 |
21 | }
22 | stage('build') {
23 | steps {
24 | sh 'mvn --version'
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_with_tool/casc.yml:
--------------------------------------------------------------------------------
1 | jenkins:
2 | systemMessage: "Jenkins for CWP CasC With Tool test\n\n"
3 | numExecutors: 5
4 | scmCheckoutRetryCount: 2
5 | mode: NORMAL
6 |
7 | tool:
8 | maven:
9 | installations:
10 | - name: maven
11 | home: /var/jenkins_home/tools/apache-maven-3.3.3
12 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_casc_with_tool/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-7
17 | docker:
18 | base: "jenkins/jenkins:2.150.3"
19 | tag: "jenkins-experimental/jenkinsfile-runner-demo"
20 | build: false
21 | war:
22 | groupId: "org.jenkins-ci.main"
23 | artifactId: "jenkins-war"
24 | source:
25 | version: "2.150.3"
26 |
27 | plugins:
28 | - groupId: "org.jenkins-ci.plugins.workflow"
29 | artifactId: "workflow-job"
30 | source:
31 | version: "2.31"
32 | - groupId: "org.jenkins-ci.plugins.workflow"
33 | artifactId: "workflow-cps"
34 | source:
35 | version: "2.63"
36 | - groupId: "org.jenkins-ci.plugins.workflow"
37 | artifactId: "workflow-cps-global-lib"
38 | source:
39 | version: "2.13"
40 | - groupId: "org.jenkins-ci.plugins.workflow"
41 | artifactId: "workflow-api"
42 | source:
43 | version: "2.33"
44 | - groupId: "org.jenkins-ci.plugins.workflow"
45 | artifactId: "workflow-step-api"
46 | source:
47 | version: "2.19"
48 | - groupId: "org.jenkins-ci.plugins.workflow"
49 | artifactId: "workflow-support"
50 | source:
51 | version: "3.2"
52 | - groupId: "org.jenkins-ci.plugins"
53 | artifactId: "pipeline-utility-steps"
54 | source:
55 | version: "2.2.0"
56 | - groupId: "org.jenkins-ci.plugins"
57 | artifactId: "cloudbees-folder"
58 | source:
59 | version: "6.4"
60 | - groupId: "org.jenkins-ci.plugins"
61 | artifactId: "credentials"
62 | source:
63 | version: "2.1.18"
64 | - groupId: "org.jenkins-ci.plugins"
65 | artifactId: "structs"
66 | source:
67 | version: "1.17"
68 | - groupId: "org.jenkins-ci.plugins"
69 | artifactId: "scm-api"
70 | source:
71 | version: "2.3.0"
72 | - groupId: "org.jenkins-ci.plugins"
73 | artifactId: "ssh-credentials"
74 | source:
75 | version: "1.14"
76 | - groupId: "org.jenkins-ci.plugins"
77 | artifactId: "credentials-binding"
78 | source:
79 | version: "1.16"
80 | - groupId: "org.jenkins-ci.plugins"
81 | artifactId: "permissive-script-security"
82 | source:
83 | version: "0.3"
84 | - groupId: "org.jenkins-ci.plugins"
85 | artifactId: "git"
86 | source:
87 | version: "3.0.0"
88 | - groupId: "org.jenkins-ci.plugins.workflow"
89 | artifactId: "workflow-aggregator"
90 | source:
91 | version: "2.5"
92 | - groupId: "io.jenkins"
93 | artifactId: "configuration-as-code"
94 | source:
95 | version: "1.5"
96 | - groupId: "io.jenkins.configuration-as-code"
97 | artifactId: "configuration-as-code-support"
98 | source:
99 | version: "1.5"
100 | systemProperties: {
101 | jenkins.model.Jenkins.slaveAgentPort: "50000",
102 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
103 | casc:
104 | - id: "casc"
105 | source:
106 | dir: ./test_resources/test_cwp_casc_with_tool/casc.yml
107 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_classloading/Jenkinsfile:
--------------------------------------------------------------------------------
1 | stage('Get class') {
2 | node {
3 | Class.forName('org.kohsuke.stapler.EvaluationTrace$ApplicationTracer')
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_classloading/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins.jenkinsfile-runner"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-7
17 | docker:
18 | base: "jenkins/jenkins:2.156"
19 | build: false
20 | war:
21 | groupId: "org.jenkins-ci.main"
22 | artifactId: "jenkins-war"
23 | source:
24 | version: "2.156"
25 | plugins:
26 | - groupId: "org.jenkins-ci.plugins.workflow"
27 | artifactId: "workflow-job"
28 | source:
29 | version: "2.24"
30 | - groupId: "org.jenkins-ci.plugins.workflow"
31 | artifactId: "workflow-cps"
32 | source:
33 | version: "2.48"
34 | - groupId: "org.jenkins-ci.plugins.workflow"
35 | artifactId: "workflow-api"
36 | source:
37 | version: "2.27"
38 | - groupId: "org.jenkins-ci.plugins.workflow"
39 | artifactId: "workflow-step-api"
40 | source:
41 | version: "2.14"
42 | - groupId: "org.jenkins-ci.plugins"
43 | artifactId: "pipeline-utility-steps"
44 | source:
45 | version: "2.1.0"
46 | - groupId: "org.jenkins-ci.plugins"
47 | artifactId: "cloudbees-folder"
48 | source:
49 | version: "6.4"
50 | - groupId: "org.jenkins-ci.plugins"
51 | artifactId: "credentials"
52 | source:
53 | version: "2.1.11"
54 | - groupId: "org.jenkins-ci.plugins"
55 | artifactId: "structs"
56 | source:
57 | version: "1.14"
58 | - groupId: "org.jenkins-ci.plugins"
59 | artifactId: "scm-api"
60 | source:
61 | version: "2.2.6"
62 | - groupId: "org.jenkins-ci.plugins"
63 | artifactId: "ssh-credentials"
64 | source:
65 | version: "1.12"
66 | - groupId: "org.jenkins-ci.plugins"
67 | artifactId: "credentials-binding"
68 | source:
69 | version: "1.16"
70 | - groupId: "org.jenkins-ci.plugins.workflow"
71 | artifactId: "workflow-aggregator"
72 | source:
73 | version: "2.5"
74 | - groupId: "io.jenkins"
75 | artifactId: "configuration-as-code"
76 | source:
77 | version: "1.1"
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_commit/Jenkinsfile:
--------------------------------------------------------------------------------
1 | stage('Get class') {
2 | node {
3 | Jenkins.instance.pluginManager.uberClassLoader.loadClass('com.cloudbees.jenkins.support.util.WordReplacer')
4 | echo Jenkins.instance.pluginManager.getPlugin('support-core').versionNumber.toString()
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_commit/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins.jenkinsfile-runner"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-7
17 | docker:
18 | base: "jenkins/jenkins:2.150.3"
19 | build: false
20 | war:
21 | groupId: "org.jenkins-ci.main"
22 | artifactId: "jenkins-war"
23 | source:
24 | version: "2.150.3"
25 | plugins:
26 | - groupId: "org.jenkins-ci.plugins.workflow"
27 | artifactId: "workflow-job"
28 | source:
29 | version: "2.24"
30 | - groupId: "org.jenkins-ci.plugins.workflow"
31 | artifactId: "workflow-cps"
32 | source:
33 | version: "2.48"
34 | - groupId: "org.jenkins-ci.plugins.workflow"
35 | artifactId: "workflow-api"
36 | source:
37 | version: "2.27"
38 | - groupId: "org.jenkins-ci.plugins.workflow"
39 | artifactId: "workflow-step-api"
40 | source:
41 | version: "2.14"
42 | - groupId: "org.jenkins-ci.plugins"
43 | artifactId: "pipeline-utility-steps"
44 | source:
45 | version: "2.1.0"
46 | - groupId: "org.jenkins-ci.plugins"
47 | artifactId: "cloudbees-folder"
48 | source:
49 | version: "6.4"
50 | - groupId: "org.jenkins-ci.plugins"
51 | artifactId: "credentials"
52 | source:
53 | version: "2.1.11"
54 | - groupId: "org.jenkins-ci.plugins"
55 | artifactId: "structs"
56 | source:
57 | version: "1.14"
58 | - groupId: "org.jenkins-ci.plugins"
59 | artifactId: "scm-api"
60 | source:
61 | version: "2.2.6"
62 | - groupId: "org.jenkins-ci.plugins"
63 | artifactId: "ssh-credentials"
64 | source:
65 | version: "1.12"
66 | - groupId: "org.jenkins-ci.plugins"
67 | artifactId: "credentials-binding"
68 | source:
69 | version: "1.16"
70 | - groupId: "org.jenkins-ci.plugins.workflow"
71 | artifactId: "workflow-aggregator"
72 | source:
73 | version: "2.5"
74 | - groupId: "io.jenkins"
75 | artifactId: "configuration-as-code"
76 | source:
77 | version: "1.1"
78 | - groupId: "org.jenkins-ci.plugins"
79 | artifactId: "support-core"
80 | source:
81 | git: "https://github.com/jenkinsci/support-core-plugin"
82 | commit: "91273a413bbd5452bd32a17f67f9bd8ac7c164c6"
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_jfr/Jenkinsfile:
--------------------------------------------------------------------------------
1 | stage('Read Evergreen YAML') {
2 | node {
3 | sh 'wget https://raw.githubusercontent.com/jenkins-infra/evergreen/master/services/essentials.yaml'
4 | def essentialsYaml = readYaml(file: "essentials.yaml")
5 | echo "Jenkins Evergreen uses the following Core version: ${essentialsYaml.spec.core.version}"
6 | }
7 | }
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_jfr/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins.jenkinsfile-runner"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-6
17 | docker:
18 | base: "jenkins/jenkins:2.150.3"
19 | build: false
20 | war:
21 | groupId: "org.jenkins-ci.main"
22 | artifactId: "jenkins-war"
23 | source:
24 | version: "2.150.3"
25 | plugins:
26 | - groupId: "org.jenkins-ci.plugins.workflow"
27 | artifactId: "workflow-job"
28 | source:
29 | version: "2.24"
30 | - groupId: "org.jenkins-ci.plugins.workflow"
31 | artifactId: "workflow-cps"
32 | source:
33 | version: "2.48"
34 | - groupId: "org.jenkins-ci.plugins.workflow"
35 | artifactId: "workflow-api"
36 | source:
37 | version: "2.27"
38 | - groupId: "org.jenkins-ci.plugins.workflow"
39 | artifactId: "workflow-step-api"
40 | source:
41 | version: "2.14"
42 | - groupId: "org.jenkins-ci.plugins"
43 | artifactId: "pipeline-utility-steps"
44 | source:
45 | version: "2.1.0"
46 | - groupId: "org.jenkins-ci.plugins"
47 | artifactId: "cloudbees-folder"
48 | source:
49 | version: "6.4"
50 | - groupId: "org.jenkins-ci.plugins"
51 | artifactId: "credentials"
52 | source:
53 | version: "2.1.11"
54 | - groupId: "org.jenkins-ci.plugins"
55 | artifactId: "structs"
56 | source:
57 | version: "1.14"
58 | - groupId: "org.jenkins-ci.plugins"
59 | artifactId: "scm-api"
60 | source:
61 | version: "2.2.6"
62 | - groupId: "org.jenkins-ci.plugins"
63 | artifactId: "ssh-credentials"
64 | source:
65 | version: "1.12"
66 | - groupId: "org.jenkins-ci.plugins"
67 | artifactId: "credentials-binding"
68 | source:
69 | version: "1.16"
70 | - groupId: "org.jenkins-ci.plugins.workflow"
71 | artifactId: "workflow-aggregator"
72 | source:
73 | version: "2.5"
74 | - groupId: "io.jenkins"
75 | artifactId: "configuration-as-code"
76 | source:
77 | version: "1.1"
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_sandbox_configuration/Jenkinsfile:
--------------------------------------------------------------------------------
1 | stage('Get class') {
2 | node {
3 | Class.forName('org.kohsuke.stapler.EvaluationTrace$ApplicationTracer')
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_sandbox_configuration/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins.jenkinsfile-runner"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-7
17 | docker:
18 | base: "jenkins/jenkins:2.156"
19 | build: false
20 | noSandbox: true
21 | war:
22 | groupId: "org.jenkins-ci.main"
23 | artifactId: "jenkins-war"
24 | source:
25 | version: "2.156"
26 | plugins:
27 | - groupId: "org.jenkins-ci.plugins.workflow"
28 | artifactId: "workflow-job"
29 | source:
30 | version: "2.24"
31 | - groupId: "org.jenkins-ci.plugins.workflow"
32 | artifactId: "workflow-cps"
33 | source:
34 | version: "2.48"
35 | - groupId: "org.jenkins-ci.plugins.workflow"
36 | artifactId: "workflow-api"
37 | source:
38 | version: "2.27"
39 | - groupId: "org.jenkins-ci.plugins.workflow"
40 | artifactId: "workflow-step-api"
41 | source:
42 | version: "2.14"
43 | - groupId: "org.jenkins-ci.plugins"
44 | artifactId: "pipeline-utility-steps"
45 | source:
46 | version: "2.1.0"
47 | - groupId: "org.jenkins-ci.plugins"
48 | artifactId: "cloudbees-folder"
49 | source:
50 | version: "6.4"
51 | - groupId: "org.jenkins-ci.plugins"
52 | artifactId: "credentials"
53 | source:
54 | version: "2.1.11"
55 | - groupId: "org.jenkins-ci.plugins"
56 | artifactId: "structs"
57 | source:
58 | version: "1.14"
59 | - groupId: "org.jenkins-ci.plugins"
60 | artifactId: "scm-api"
61 | source:
62 | version: "2.2.6"
63 | - groupId: "org.jenkins-ci.plugins"
64 | artifactId: "ssh-credentials"
65 | source:
66 | version: "1.12"
67 | - groupId: "org.jenkins-ci.plugins"
68 | artifactId: "credentials-binding"
69 | source:
70 | version: "1.16"
71 | - groupId: "org.jenkins-ci.plugins.workflow"
72 | artifactId: "workflow-aggregator"
73 | source:
74 | version: "2.5"
75 | - groupId: "io.jenkins"
76 | artifactId: "configuration-as-code"
77 | source:
78 | version: "1.1"
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_with_groovy_hooks/Jenkinsfile:
--------------------------------------------------------------------------------
1 | pipeline {
2 | agent any
3 | stages {
4 |
5 | stage('build') {
6 | steps {
7 | echo "Nothing needed here at the moment"
8 | }
9 | }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_with_groovy_hooks/init.groovy:
--------------------------------------------------------------------------------
1 | // Just a stub Groovy initialization hook
2 | println("******************************************************************************")
3 | println("-- System configuration by Groovy Hooks")
4 | println("******************************************************************************")
5 |
6 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_with_groovy_hooks/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-7
17 | docker:
18 | base: "jenkins/jenkins:2.150.3"
19 | tag: "jenkins-experimental/jenkinsfile-runner-demo"
20 | build: false
21 | war:
22 | groupId: "org.jenkins-ci.main"
23 | artifactId: "jenkins-war"
24 | source:
25 | version: "2.150.3"
26 |
27 | # TODO I don't think we need all of the plugins here; see the ones that were addded for the pipeline library test
28 | plugins:
29 | - groupId: "org.jenkins-ci.plugins.workflow"
30 | artifactId: "workflow-job"
31 | source:
32 | version: "2.31"
33 | - groupId: "org.jenkins-ci.plugins.workflow"
34 | artifactId: "workflow-cps"
35 | source:
36 | version: "2.63"
37 | - groupId: "org.jenkins-ci.plugins.workflow"
38 | artifactId: "workflow-cps-global-lib"
39 | source:
40 | version: "2.13"
41 | - groupId: "org.jenkins-ci.plugins.workflow"
42 | artifactId: "workflow-api"
43 | source:
44 | version: "2.33"
45 | - groupId: "org.jenkins-ci.plugins.workflow"
46 | artifactId: "workflow-step-api"
47 | source:
48 | version: "2.19"
49 | - groupId: "org.jenkins-ci.plugins.workflow"
50 | artifactId: "workflow-support"
51 | source:
52 | version: "3.2"
53 | - groupId: "org.jenkins-ci.plugins"
54 | artifactId: "pipeline-utility-steps"
55 | source:
56 | version: "2.2.0"
57 | - groupId: "org.jenkins-ci.plugins"
58 | artifactId: "cloudbees-folder"
59 | source:
60 | version: "6.4"
61 | - groupId: "org.jenkins-ci.plugins"
62 | artifactId: "credentials"
63 | source:
64 | version: "2.1.18"
65 | - groupId: "org.jenkins-ci.plugins"
66 | artifactId: "structs"
67 | source:
68 | version: "1.17"
69 | - groupId: "org.jenkins-ci.plugins"
70 | artifactId: "scm-api"
71 | source:
72 | version: "2.3.0"
73 | - groupId: "org.jenkins-ci.plugins"
74 | artifactId: "ssh-credentials"
75 | source:
76 | version: "1.14"
77 | - groupId: "org.jenkins-ci.plugins"
78 | artifactId: "credentials-binding"
79 | source:
80 | version: "1.16"
81 | - groupId: "org.jenkins-ci.plugins"
82 | artifactId: "permissive-script-security"
83 | source:
84 | version: "0.3"
85 | - groupId: "org.jenkins-ci.plugins"
86 | artifactId: "git"
87 | source:
88 | version: "3.0.0"
89 | - groupId: "org.jenkins-ci.plugins.workflow"
90 | artifactId: "workflow-aggregator"
91 | source:
92 | version: "2.5"
93 | - groupId: "io.jenkins"
94 | artifactId: "configuration-as-code"
95 | source:
96 | version: "1.5"
97 | - groupId: "io.jenkins.configuration-as-code"
98 | artifactId: "configuration-as-code-support"
99 | source:
100 | version: "1.5"
101 | systemProperties: {
102 | jenkins.model.Jenkins.slaveAgentPort: "50000",
103 | jenkins.model.Jenkins.slaveAgentPortEnforce: "true"}
104 | groovyHooks:
105 | - type: "init"
106 | id: "initScripts"
107 | source:
108 | dir: ./test_resources/test_cwp_with_groovy_hooks/init.groovy
109 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_workspace/Jenkinsfile:
--------------------------------------------------------------------------------
1 | stage('Write message') {
2 | node {
3 | writeFile file: 'message.txt', text: 'This is the message to find in the logs'
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_workspace/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins.jenkinsfile-runner"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-6
17 | docker:
18 | base: "jenkins/jenkins:2.150.3"
19 | build: false
20 | war:
21 | groupId: "org.jenkins-ci.main"
22 | artifactId: "jenkins-war"
23 | source:
24 | version: "2.150.3"
25 | plugins:
26 | - groupId: "org.jenkins-ci.plugins.workflow"
27 | artifactId: "workflow-job"
28 | source:
29 | version: "2.24"
30 | - groupId: "org.jenkins-ci.plugins.workflow"
31 | artifactId: "workflow-cps"
32 | source:
33 | version: "2.48"
34 | - groupId: "org.jenkins-ci.plugins.workflow"
35 | artifactId: "workflow-api"
36 | source:
37 | version: "2.27"
38 | - groupId: "org.jenkins-ci.plugins.workflow"
39 | artifactId: "workflow-step-api"
40 | source:
41 | version: "2.14"
42 | - groupId: "org.jenkins-ci.plugins"
43 | artifactId: "pipeline-utility-steps"
44 | source:
45 | version: "2.1.0"
46 | - groupId: "org.jenkins-ci.plugins"
47 | artifactId: "cloudbees-folder"
48 | source:
49 | version: "6.4"
50 | - groupId: "org.jenkins-ci.plugins"
51 | artifactId: "credentials"
52 | source:
53 | version: "2.1.11"
54 | - groupId: "org.jenkins-ci.plugins"
55 | artifactId: "structs"
56 | source:
57 | version: "1.14"
58 | - groupId: "org.jenkins-ci.plugins"
59 | artifactId: "scm-api"
60 | source:
61 | version: "2.2.6"
62 | - groupId: "org.jenkins-ci.plugins"
63 | artifactId: "ssh-credentials"
64 | source:
65 | version: "1.12"
66 | - groupId: "org.jenkins-ci.plugins"
67 | artifactId: "credentials-binding"
68 | source:
69 | version: "1.16"
70 | - groupId: "org.jenkins-ci.plugins.workflow"
71 | artifactId: "workflow-aggregator"
72 | source:
73 | version: "2.5"
74 | - groupId: "io.jenkins"
75 | artifactId: "configuration-as-code"
76 | source:
77 | version: "1.1"
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_workspace_non_default/Jenkinsfile:
--------------------------------------------------------------------------------
1 | stage('Write message') {
2 | node {
3 | writeFile file: 'message.txt', text: 'This is the message to find in the logs'
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_cwp_workspace_non_default/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.custom-war-packager.demo"
3 | artifactId: "jenkinsfile-runner"
4 | vendor: "Jenkins project"
5 | title: "Jenkinsfile Runner demo"
6 | description: "Jenkinsfile Runner Docker Image, produced by Custom WAR Packager"
7 | buildSettings:
8 | jenkinsfileRunner:
9 | source:
10 | groupId: "io.jenkins.jenkinsfile-runner"
11 | artifactId: "jenkinsfile-runner"
12 | build:
13 | noCache: true
14 | source:
15 | git: https://github.com/jenkinsci/jenkinsfile-runner.git
16 | branch: 1.0-beta-6
17 | docker:
18 | base: "jenkins/jenkins:2.150.3"
19 | build: false
20 | runWorkspace: "/anotherBuildDirectory"
21 | war:
22 | groupId: "org.jenkins-ci.main"
23 | artifactId: "jenkins-war"
24 | source:
25 | version: "2.150.3"
26 | plugins:
27 | - groupId: "org.jenkins-ci.plugins.workflow"
28 | artifactId: "workflow-job"
29 | source:
30 | version: "2.24"
31 | - groupId: "org.jenkins-ci.plugins.workflow"
32 | artifactId: "workflow-cps"
33 | source:
34 | version: "2.48"
35 | - groupId: "org.jenkins-ci.plugins.workflow"
36 | artifactId: "workflow-api"
37 | source:
38 | version: "2.27"
39 | - groupId: "org.jenkins-ci.plugins.workflow"
40 | artifactId: "workflow-step-api"
41 | source:
42 | version: "2.14"
43 | - groupId: "org.jenkins-ci.plugins"
44 | artifactId: "pipeline-utility-steps"
45 | source:
46 | version: "2.1.0"
47 | - groupId: "org.jenkins-ci.plugins"
48 | artifactId: "cloudbees-folder"
49 | source:
50 | version: "6.4"
51 | - groupId: "org.jenkins-ci.plugins"
52 | artifactId: "credentials"
53 | source:
54 | version: "2.1.11"
55 | - groupId: "org.jenkins-ci.plugins"
56 | artifactId: "structs"
57 | source:
58 | version: "1.14"
59 | - groupId: "org.jenkins-ci.plugins"
60 | artifactId: "scm-api"
61 | source:
62 | version: "2.2.6"
63 | - groupId: "org.jenkins-ci.plugins"
64 | artifactId: "ssh-credentials"
65 | source:
66 | version: "1.12"
67 | - groupId: "org.jenkins-ci.plugins"
68 | artifactId: "credentials-binding"
69 | source:
70 | version: "1.16"
71 | - groupId: "org.jenkins-ci.plugins.workflow"
72 | artifactId: "workflow-aggregator"
73 | source:
74 | version: "2.5"
75 | - groupId: "io.jenkins"
76 | artifactId: "configuration-as-code"
77 | source:
78 | version: "1.1"
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_from_pom/packager-config-with-dependency.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.121.1"
8 | tag: "jenkins/demo-pom-input"
9 | build: true
10 | pom: ./test_resources/test_war_from_pom/pom-with-dependency.xml
11 | pomIgnoreRoot: true
12 | pomIncludeWar: true
13 | war:
14 | groupId: "org.jenkins-ci.main"
15 | artifactId: "jenkins-war"
16 | source:
17 | version: 2.121.1
18 |
19 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_from_pom/packager-config-with-property.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.121.1"
8 | tag: "jenkins/demo-pom-input"
9 | build: true
10 | pom: ./test_resources/test_war_from_pom/pom-with-property.xml
11 | pomIgnoreRoot: true
12 | pomIncludeWar: true
13 | war:
14 | groupId: "org.jenkins-ci.main"
15 | artifactId: "jenkins-war"
16 | source:
17 | version: 2.121.1
18 |
19 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_from_pom/packager-config-with-war-property.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.121.1"
8 | tag: "jenkins/demo-pom-input"
9 | build: true
10 | pom: ./test_resources/test_war_from_pom/pom-with-war-property.xml
11 | pomIgnoreRoot: true
12 | pomIncludeWar: true
13 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_from_pom/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.121.1"
8 | tag: "jenkins/demo-pom-input"
9 | build: true
10 | pom: ./test_resources/test_war_from_pom/pom.xml
11 | pomIgnoreRoot: true
12 | war:
13 | groupId: "org.jenkins-ci.main"
14 | artifactId: "jenkins-war"
15 | source:
16 | version: 2.121.1
17 |
18 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_from_pom/pom-with-dependency.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jenkins-ci.plugins
7 | plugin
8 | 3.2
9 |
10 |
11 |
12 | cloudbees-folder
13 | 6.8-SNAPSHOT
14 | hpi
15 |
16 | Folders Plugin
17 | This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (like
18 | by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
19 |
20 | https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin
21 |
22 | 2.130
23 | 8
24 | false
25 |
26 |
27 |
28 | MIT
29 | https://opensource.org/licenses/MIT
30 |
31 |
32 |
33 |
34 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git
35 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
36 | https://github.com/jenkinsci/${project.artifactId}-plugin
37 | HEAD
38 |
39 |
40 |
41 |
42 | repo.jenkins-ci.org
43 | https://repo.jenkins-ci.org/public/
44 |
45 |
46 |
47 |
48 | repo.jenkins-ci.org
49 | https://repo.jenkins-ci.org/public/
50 |
51 |
52 |
53 |
54 |
55 | org.jenkins-ci.main
56 | jenkins-core
57 | 2.150.3
58 |
59 |
60 | org.jenkins-ci.plugins
61 | credentials
62 | 2.1.11
63 | true
64 |
65 |
66 | org.jenkins-ci.plugins
67 | matrix-auth
68 | 2.0
69 | test
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.jenkins-ci.tools
77 | maven-hpi-plugin
78 |
79 | 5.2
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_from_pom/pom-with-property.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jenkins-ci.plugins
7 | plugin
8 | 3.2
9 |
10 |
11 |
12 | cloudbees-folder
13 | 6.8-SNAPSHOT
14 | hpi
15 |
16 | Folders Plugin
17 | This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (like
18 | by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
19 |
20 | https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin
21 |
22 | 2.130
23 | 8
24 | false
25 |
26 |
27 |
28 | MIT
29 | https://opensource.org/licenses/MIT
30 |
31 |
32 |
33 |
34 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git
35 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
36 | https://github.com/jenkinsci/${project.artifactId}-plugin
37 | HEAD
38 |
39 |
40 |
41 |
42 | repo.jenkins-ci.org
43 | https://repo.jenkins-ci.org/public/
44 |
45 |
46 |
47 |
48 | repo.jenkins-ci.org
49 | https://repo.jenkins-ci.org/public/
50 |
51 |
52 |
53 |
54 |
55 | org.jenkins-ci.plugins
56 | credentials
57 | 2.1.11
58 | true
59 |
60 |
61 | org.jenkins-ci.plugins
62 | matrix-auth
63 | 2.0
64 | test
65 |
66 |
67 |
68 |
69 |
70 |
71 | org.jenkins-ci.tools
72 | maven-hpi-plugin
73 |
74 | 5.2
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_from_pom/pom-with-war-property.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jenkins-ci.plugins
7 | plugin
8 | 3.2
9 |
10 |
11 |
12 | cloudbees-folder
13 | 6.8-SNAPSHOT
14 | hpi
15 |
16 | Folders Plugin
17 | This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (like
18 | by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
19 |
20 | https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin
21 |
22 | 2.150.3
23 | 2.130
24 | 8
25 | false
26 |
27 |
28 |
29 | MIT
30 | https://opensource.org/licenses/MIT
31 |
32 |
33 |
34 |
35 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git
36 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
37 | https://github.com/jenkinsci/${project.artifactId}-plugin
38 | HEAD
39 |
40 |
41 |
42 |
43 | repo.jenkins-ci.org
44 | https://repo.jenkins-ci.org/public/
45 |
46 |
47 |
48 |
49 | repo.jenkins-ci.org
50 | https://repo.jenkins-ci.org/public/
51 |
52 |
53 |
54 |
55 |
56 | org.jenkins-ci.plugins
57 | credentials
58 | 2.1.11
59 | true
60 |
61 |
62 | org.jenkins-ci.plugins
63 | matrix-auth
64 | 2.0
65 | test
66 |
67 |
68 |
69 |
70 |
71 |
72 | org.jenkins-ci.tools
73 | maven-hpi-plugin
74 |
75 | 5.2
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_from_pom/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jenkins-ci.plugins
7 | plugin
8 | 3.2
9 |
10 |
11 |
12 | cloudbees-folder
13 | 6.8-SNAPSHOT
14 | hpi
15 |
16 | Folders Plugin
17 | This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (like
18 | by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
19 |
20 | https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin
21 |
22 | false
23 |
24 |
25 |
26 | MIT
27 | https://opensource.org/licenses/MIT
28 |
29 |
30 |
31 |
32 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git
33 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
34 | https://github.com/jenkinsci/${project.artifactId}-plugin
35 | HEAD
36 |
37 |
38 |
39 |
40 | repo.jenkins-ci.org
41 | https://repo.jenkins-ci.org/public/
42 |
43 |
44 |
45 |
46 | repo.jenkins-ci.org
47 | https://repo.jenkins-ci.org/public/
48 |
49 |
50 |
51 |
52 |
53 | org.jenkins-ci.plugins
54 | credentials
55 | 2.1.11
56 | true
57 |
58 |
59 | org.jenkins-ci.plugins
60 | matrix-auth
61 | 2.0
62 | test
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.jenkins-ci.tools
70 | maven-hpi-plugin
71 |
72 | 5.2
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_not_from_pom/packager-config-with-dependency.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.121.1"
8 | tag: "jenkins/demo-pom-input"
9 | build: true
10 | pom: ./test_resources/test_war_from_pom/pom-with-dependency.xml
11 | pomIgnoreRoot: true
12 | war:
13 | groupId: "org.jenkins-ci.main"
14 | artifactId: "jenkins-war"
15 | source:
16 | version: 2.121.1
17 |
18 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_not_from_pom/packager-config-with-property.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.121.1"
8 | tag: "jenkins/demo-pom-input"
9 | build: true
10 | pom: ./test_resources/test_war_from_pom/pom-with-property.xml
11 | pomIgnoreRoot: true
12 | war:
13 | groupId: "org.jenkins-ci.main"
14 | artifactId: "jenkins-war"
15 | source:
16 | version: 2.121.1
17 |
18 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_not_from_pom/packager-config-with-war-property.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.121.1"
8 | tag: "jenkins/demo-pom-input"
9 | build: true
10 | pom: ./test_resources/test_war_from_pom/pom-with-war-property.xml
11 | pomIgnoreRoot: true
12 | war:
13 | groupId: "org.jenkins-ci.main"
14 | artifactId: "jenkins-war"
15 | source:
16 | version: 2.121.1
17 |
18 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_not_from_pom/packager-config.yml:
--------------------------------------------------------------------------------
1 | bundle:
2 | groupId: "io.jenkins.tools.war-packager.demo"
3 | artifactId: "pom-input-demo"
4 | vendor: "Jenkins project"
5 | buildSettings:
6 | docker:
7 | base: "jenkins/jenkins:2.121.1"
8 | tag: "jenkins/demo-pom-input"
9 | build: true
10 | pom: ./test_resources/test_war_from_pom/pom.xml
11 | pomIgnoreRoot: true
12 | war:
13 | groupId: "org.jenkins-ci.main"
14 | artifactId: "jenkins-war"
15 | source:
16 | version: 2.121.1
17 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_not_from_pom/pom-with-dependency.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jenkins-ci.plugins
7 | plugin
8 | 3.2
9 |
10 |
11 |
12 | cloudbees-folder
13 | 6.8-SNAPSHOT
14 | hpi
15 |
16 | Folders Plugin
17 | This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (like
18 | by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
19 |
20 | https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin
21 |
22 | 2.130
23 | 8
24 | false
25 |
26 |
27 |
28 | MIT
29 | https://opensource.org/licenses/MIT
30 |
31 |
32 |
33 |
34 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git
35 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
36 | https://github.com/jenkinsci/${project.artifactId}-plugin
37 | HEAD
38 |
39 |
40 |
41 |
42 | repo.jenkins-ci.org
43 | https://repo.jenkins-ci.org/public/
44 |
45 |
46 |
47 |
48 | repo.jenkins-ci.org
49 | https://repo.jenkins-ci.org/public/
50 |
51 |
52 |
53 |
54 |
55 | org.jenkins-ci.main
56 | jenkins-core
57 | 2.150.3
58 |
59 |
60 | org.jenkins-ci.plugins
61 | credentials
62 | 2.1.11
63 | true
64 |
65 |
66 | org.jenkins-ci.plugins
67 | matrix-auth
68 | 2.0
69 | test
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.jenkins-ci.tools
77 | maven-hpi-plugin
78 |
79 | 5.2
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_not_from_pom/pom-with-property.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jenkins-ci.plugins
7 | plugin
8 | 3.2
9 |
10 |
11 |
12 | cloudbees-folder
13 | 6.8-SNAPSHOT
14 | hpi
15 |
16 | Folders Plugin
17 | This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (like
18 | by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
19 |
20 | https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin
21 |
22 | 2.130
23 | 8
24 | false
25 |
26 |
27 |
28 | MIT
29 | https://opensource.org/licenses/MIT
30 |
31 |
32 |
33 |
34 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git
35 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
36 | https://github.com/jenkinsci/${project.artifactId}-plugin
37 | HEAD
38 |
39 |
40 |
41 |
42 | repo.jenkins-ci.org
43 | https://repo.jenkins-ci.org/public/
44 |
45 |
46 |
47 |
48 | repo.jenkins-ci.org
49 | https://repo.jenkins-ci.org/public/
50 |
51 |
52 |
53 |
54 |
55 | org.jenkins-ci.plugins
56 | credentials
57 | 2.1.11
58 | true
59 |
60 |
61 | org.jenkins-ci.plugins
62 | matrix-auth
63 | 2.0
64 | test
65 |
66 |
67 |
68 |
69 |
70 |
71 | org.jenkins-ci.tools
72 | maven-hpi-plugin
73 |
74 | 5.2
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_not_from_pom/pom-with-war-property.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jenkins-ci.plugins
7 | plugin
8 | 3.2
9 |
10 |
11 |
12 | cloudbees-folder
13 | 6.8-SNAPSHOT
14 | hpi
15 |
16 | Folders Plugin
17 | This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (like
18 | by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
19 |
20 | https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin
21 |
22 | 2.150.3
23 | 2.130
24 | 8
25 | false
26 |
27 |
28 |
29 | MIT
30 | https://opensource.org/licenses/MIT
31 |
32 |
33 |
34 |
35 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git
36 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
37 | https://github.com/jenkinsci/${project.artifactId}-plugin
38 | HEAD
39 |
40 |
41 |
42 |
43 | repo.jenkins-ci.org
44 | https://repo.jenkins-ci.org/public/
45 |
46 |
47 |
48 |
49 | repo.jenkins-ci.org
50 | https://repo.jenkins-ci.org/public/
51 |
52 |
53 |
54 |
55 |
56 | org.jenkins-ci.plugins
57 | credentials
58 | 2.1.11
59 | true
60 |
61 |
62 | org.jenkins-ci.plugins
63 | matrix-auth
64 | 2.0
65 | test
66 |
67 |
68 |
69 |
70 |
71 |
72 | org.jenkins-ci.tools
73 | maven-hpi-plugin
74 |
75 | 5.2
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/jenkinsfile-runner-tests/test_resources/test_war_not_from_pom/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jenkins-ci.plugins
7 | plugin
8 | 3.2
9 |
10 |
11 |
12 | cloudbees-folder
13 | 6.8-SNAPSHOT
14 | hpi
15 |
16 | Folders Plugin
17 | This plugin allows users to create "folders" to organize jobs. Users can define custom taxonomies (like
18 | by project type, organization type etc). Folders are nestable and you can define views within folders. Maintained by CloudBees, Inc.
19 |
20 | https://wiki.jenkins.io/display/JENKINS/CloudBees+Folders+Plugin
21 |
22 | false
23 |
24 |
25 |
26 | MIT
27 | https://opensource.org/licenses/MIT
28 |
29 |
30 |
31 |
32 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git
33 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git
34 | https://github.com/jenkinsci/${project.artifactId}-plugin
35 | HEAD
36 |
37 |
38 |
39 |
40 | repo.jenkins-ci.org
41 | https://repo.jenkins-ci.org/public/
42 |
43 |
44 |
45 |
46 | repo.jenkins-ci.org
47 | https://repo.jenkins-ci.org/public/
48 |
49 |
50 |
51 |
52 |
53 | org.jenkins-ci.plugins
54 | credentials
55 | 2.3.19
56 | true
57 |
58 |
59 | org.jenkins-ci.plugins
60 | matrix-auth
61 | 2.0
62 | test
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.jenkins-ci.tools
70 | maven-hpi-plugin
71 |
72 | 5.2
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/packaging/docker-builder/Dockerfile:
--------------------------------------------------------------------------------
1 | ###
2 | # Image name: onenashev/custom-war-packager-builder
3 | ###
4 | FROM maven:3.5.0-jdk-8
5 | MAINTAINER Oleg Nenashev
6 |
7 | LABEL Description="This is a Jenkins agent image, which packages tools needed by Jenkins Custom WAR Packager" Vendor="Jenkins project" Version="0.1"
8 |
9 | RUN apt-get -y update \
10 | && apt-get install -y git \
11 | && rm -rf /var/lib/apt/lists/*
12 |
13 | # Install Docker Client, we won't start a daemon
14 | ENV DOCKERVERSION=17.12.0-ce
15 | RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \
16 | && mv docker-${DOCKERVERSION}.tgz docker.tgz \
17 | && tar xzvf docker.tgz \
18 | && mv docker/docker /usr/local/bin \
19 | && rm -r docker docker.tgz
20 |
21 | ENV HOME /home/jenkins
22 | RUN groupadd -g 10000 jenkins \
23 | && groupadd -g 999 docker-users \
24 | && useradd -c "Jenkins user" -d $HOME -u 10000 -g 10000 -G jenkins,docker-users -m jenkins
25 |
26 | USER jenkins
27 | VOLUME /var/run/docker.sock
28 | WORKDIR /home/jenkins
29 |
--------------------------------------------------------------------------------
/packaging/docker-builder/README.md:
--------------------------------------------------------------------------------
1 | Docker Package for Custom WAR Packager Environment
2 | ===
3 |
4 | This image packages all tools needed by Custom WAR Packager to operate correctly.
5 | It **DOES NOT** include the Custom WAR Packager itself, the tool should be retrieved from a Maven plugin.
6 |
7 | ### Usage
8 |
9 | The image can be used within Jenkins Pipeline definitions.
10 | In the [Custom WAR Packager CI Demo](https://github.com/oleg-nenashev/jenkins-custom-war-packager-ci-demo) uses this image from the 'docker' label
11 | (the agent is provisioned by a Cloud plugin like Kubernetes or Docker plugin).
12 |
13 | ### Building Image
14 |
15 | ```sh
16 | docker build -t onenashev/custom-war-packager-builder .
17 | ```
18 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 |
4 |
5 | org.jenkins-ci
6 | jenkins
7 | 1.54
8 |
9 |
10 |
11 | 8
12 |
13 | 3.8.1
14 |
15 |
16 | io.jenkins.tools.custom-war-packager
17 | parent-pom
18 | 2.0-alpha-7-SNAPSHOT
19 | Jenkins Custom WAR Packager Parent POM
20 | Parent POM for packaging custom Jenkins WARs
21 | pom
22 | http://github.com/jenkinsci/custom-war-packager
23 |
24 |
25 | custom-war-packager-lib
26 | custom-war-packager-cli
27 | custom-war-packager-maven-plugin
28 | jenkinsfile-runner-tests
29 |
30 |
31 |
32 |
33 | The MIT license
34 | https://opensource.org/licenses/MIT
35 | repo
36 |
37 |
38 |
39 |
40 | scm:git:ssh://git@github.com/jenkinsci/custom-war-packager.git
41 | scm:git:ssh://git@github.com/jenkinsci/custom-war-packager.git
42 | http://github.com/jenkinsci/custom-war-packager
43 | HEAD
44 |
45 |
46 |
47 |
48 | repo.jenkins-ci.org
49 | https://repo.jenkins-ci.org/public/
50 |
51 |
52 |
53 |
54 |
55 | repo.jenkins-ci.org
56 | https://repo.jenkins-ci.org/public/
57 |
58 |
59 |
60 |
61 |
62 | com.google.code.findbugs
63 | annotations
64 | 3.0.1u2
65 |
66 |
67 |
68 |
69 | junit
70 | junit
71 | test
72 |
73 |
74 | org.jenkins-ci
75 | test-annotations
76 | 1.3
77 | test
78 |
79 |
80 |
81 |
82 |
83 |
84 | org.apache.maven.plugins
85 | maven-release-plugin
86 |
87 | v@{project.version}
88 |
89 |
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------