Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkins 58069 refiled for jenkinsfile use #161

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,40 @@ itBranches['buildtriggerbadge:2.10 tests success on JDK8'] = {
}
}

itBranches['CasC tests success'] = {
node('linux') {
checkout scm

stage('Build PCT CLI') {
withEnv([
"JAVA_HOME=${tool 'jdk8'}",
"PATH+MVN=${tool 'mvn'}/bin",
'PATH+JDK=$JAVA_HOME/bin',
]) {
sh 'make allNoDocker'
}
}

stage("Run known successful case(s)") {
withEnv([
"JAVA_HOME=${tool 'jdk8'}",
"PATH+MVN=${tool 'mvn'}/bin",
'PATH+JDK=$JAVA_HOME/bin',
]) {
sh '''java -jar plugins-compat-tester-cli/target/plugins-compat-tester-cli.jar \
-reportFile $(pwd)/out/pct-report.xml \
-workDirectory $(pwd)/out/work \
-skipTestCache true \
-includePlugins configuration-as-code
'''

archiveArtifacts artifacts: "out/**"

sh 'cat out/pct-report.html | grep "Tests : Success"'
}
}
}
}

itBranches.failFast = false
parallel itBranches
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ JENKINS_VERSION=2.164.3
.PHONY: all
all: clean package docker

.PHONY: allNoDocker
allNoDocker: clean package

.PHONY: clean
clean:
mvn clean

plugins-compat-tester-cli/target/plugins-compat-tester-cli.jar:
mvn verify
mvn package
.PHONY: package
package: plugins-compat-tester-cli/target/plugins-compat-tester-cli.jar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Map;

/**
* An abstract class that marks a hook that runs before the compilation stage of the
* An abstract class that marks a hook that runs before the execution stage of the
* Plugins Compat Tester.
*
* This exists simply for the ability to check when a subclass should be implemented.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.jenkins.tools.test.hook;

import hudson.model.UpdateSite;
import org.jenkins.tools.test.model.PomData;

import java.util.Map;

public class ConfigurationAsCodeHook extends AbstractMultiParentHook {

@Override
protected String getParentFolder() {
return "configuration-as-code-plugin";
}

@Override
protected String getParentUrl() {
return "scm:git:git://github.com/jenkinsci/configuration-as-code-plugin.git";
}

@Override
protected String getParentProjectName() {
return "configuration-as-code";
}

@Override
public boolean check(Map<String, Object> info) {
return isCascPlugin(info);
}

@Override
protected String getPluginFolderName(UpdateSite.Plugin currentPlugin) {
return "plugin";
}

public static boolean isCascPlugin(Map<String, Object> moreInfo) {
PomData data = (PomData) moreInfo.get("pomData");
return isCascPlugin(data);
}

public static boolean isCascPlugin(PomData data) {
if (data.parent != null) {
// Non-incrementals
return data.parent.groupId.equalsIgnoreCase("io.jenkins.configuration-as-code");
}

return "configuration-as-code".equalsIgnoreCase(data.artifactId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception
try {
System.out.println("Executing multi-parent compile hook");
PluginCompatTesterConfig config = (PluginCompatTesterConfig) moreInfo.get("config");
MavenCoordinates core = (MavenCoordinates) moreInfo.get("core");

runner = config.getExternalMaven() == null ? new InternalMavenRunner() : new ExternalMavenRunner(config.getExternalMaven());
mavenConfig = getMavenConfig(config);
Expand Down Expand Up @@ -85,7 +84,7 @@ public void validate(Map<String, Object> toCheck) throws Exception {

@Override
public boolean check(Map<String, Object> info) throws Exception {
return BlueOceanHook.isBOPlugin(info) || DeclarativePipelineHook.isDPPlugin(info) || StructsHook.isStructsPlugin(info);
return BlueOceanHook.isBOPlugin(info) || DeclarativePipelineHook.isDPPlugin(info) || StructsHook.isStructsPlugin(info) || ConfigurationAsCodeHook.isCascPlugin(info);
}

private boolean isEslintFile(Path file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public boolean check(Map<String, Object> info) {
boolean isStructs = StructsHook.isStructsPlugin(pomData);
boolean isBO = BlueOceanHook.isBOPlugin(pomData);
boolean isDeclarativePipeline = DeclarativePipelineHook.isDPPlugin(pomData);
boolean isCasC = ConfigurationAsCodeHook.isCascPlugin(pomData);
boolean pluginPOM = pomData.isPluginPOM();
if (parent != null) {
isCB = parent.matches("com.cloudbees.jenkins.plugins", "jenkins-plugins") ||
Expand All @@ -56,7 +57,7 @@ public boolean check(Map<String, Object> info) {
boolean coreRequiresNewParentPOM = coreCoordinates.compareVersionTo(CORE_NEW_PARENT_POM) >= 0;
boolean coreRequiresPluginOver233 = coreCoordinates.compareVersionTo(CORE_WITHOUT_WAR_FOR_TEST) >= 0;

if (isDeclarativePipeline || isBO || isCB || isStructs || (pluginPOM && parentV2)) {
if (isDeclarativePipeline || isBO || isCB || isStructs || isCasC || (pluginPOM && parentV2)) {
List<String> argsToMod = (List<String>)info.get("args");
argsToMod.add("-Djenkins.version=" + coreCoordinates.version);
// There are rules that avoid dependencies on a higher java level. Depending on the baselines and target cores
Expand Down