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

Fix Acceptance tests #504

Merged
merged 17 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
24 changes: 6 additions & 18 deletions acceptance-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ plugins {
val ciJenkinsBuild: Boolean by (gradle as ExtensionAware).extra

java {
// Only used for compilation. We don't rely on toolchain for running the tests,
// as Jenkins ATH doesn't allow to specify the JAVA_HOME.
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
Expand Down Expand Up @@ -40,18 +42,13 @@ dependencies {
add(gradlePlugin.name, project(path = ":", configuration = "gradlePluginJpi"))
}

val currentJava = JavaVersion.current()

val jenkinsVersions = listOf(
JenkinsVersion.LATEST,
JenkinsVersion.LATEST_LTS,
JenkinsVersion.V2_401
)

jenkinsVersions
.filter { jenkinsVersion ->
jenkinsVersion.isDefault || currentJava.isCompatibleWith(jenkinsVersion.requiredJavaVersion)
}
.forEach { jenkinsVersion ->
val downloadJenkinsTask =
tasks.register<Download>("downloadJenkins${jenkinsVersion.label}") {
Expand Down Expand Up @@ -85,10 +82,6 @@ jenkinsVersions
!ciJenkinsBuild && !OperatingSystem.current().isWindows
}

javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(jenkinsVersion.javaVersion)
})

systemProperties(
mapOf(
"jdk.xml.xpathExprOpLimit" to 150
Expand All @@ -107,7 +100,7 @@ jenkinsVersions
}
}

data class JenkinsVersion(val version: String, val downloadUrl: URL, val javaVersion: JavaLanguageVersion) {
data class JenkinsVersion(val version: String, val downloadUrl: URL) {

companion object {

Expand All @@ -119,14 +112,11 @@ data class JenkinsVersion(val version: String, val downloadUrl: URL, val javaVer

private val JENKINS_VERSION_PATTERN = "^\\d+([.]\\d+)*?\$".toRegex()

private val JAVA_11 = JavaLanguageVersion.of(11)
private val JAVA_17 = JavaLanguageVersion.of(17)

val LATEST = of(LATEST_VERSION, JAVA_17)
val LATEST = of(LATEST_VERSION)
val LATEST_LTS = of(LATEST_LTS_VERSION)
val V2_401 = of(V2_401_VERSION)

private fun of(version: String, javaVersion: JavaLanguageVersion = JAVA_11): JenkinsVersion {
private fun of(version: String): JenkinsVersion {
val downloadUrl =
when (version) {
LATEST_VERSION -> "${MIRROR}/current/latest/jenkins.war"
Expand All @@ -139,7 +129,7 @@ data class JenkinsVersion(val version: String, val downloadUrl: URL, val javaVer
}
}

return JenkinsVersion(version, URL(downloadUrl), javaVersion)
return JenkinsVersion(version, URL(downloadUrl))
}

private fun isJenkinsVersion(version: String) = JENKINS_VERSION_PATTERN.matches(version)
Expand All @@ -155,6 +145,4 @@ data class JenkinsVersion(val version: String, val downloadUrl: URL, val javaVer
version.split("-").joinToString(separator = "") { it.capitalized() }
}

val requiredJavaVersion: JavaVersion
get() = JavaVersion.toVersion(javaVersion.toString())
}
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ plugins {
group = "org.jenkins-ci.plugins"
description = "This plugin adds Gradle support to Jenkins"

val coreBaseVersion = "2.401"
val coreBaseVersion = "2.440"
val corePatchVersion = "3"
val coreBomVersion = "2745.vc7b_fe4c876fa_"
val coreBomVersion = "3387.v0f2773fa_3200"

val gradleExt = (gradle as ExtensionAware).extra

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ class BuildScanIntegrationTest extends BaseGradleIntegrationTest {

def 'detects build scan in pipeline log'() {
given:
gradleInstallationRule.gradleVersion = '7.3.3'
gradleInstallationRule.addInstallation()
def pipelineJob = j.createProject(WorkflowJob)
pipelineJob.setDefinition(new CpsFlowDefinition("""
node {
stage('Build') {
// Run the maven build
def gradleHome = tool name: '5.5', type: 'gradle'
def gradleHome = tool name: '${gradleInstallationRule.gradleVersion}', type: 'gradle'
writeFile file: 'settings.gradle', text: ''
writeFile file: 'build.gradle', text: "buildScan { termsOfServiceUrl = 'https://gradle.com/terms-of-service'; termsOfServiceAgree = 'yes' }"
if (isUnix()) {
Expand Down Expand Up @@ -125,7 +126,7 @@ node {

def 'detects build scan in pipeline log using withGradle'() {
given:
gradleInstallationRule.gradleVersion = '5.6.4'
gradleInstallationRule.gradleVersion = '7.3.3'
gradleInstallationRule.addInstallation()
def pipelineJob = j.createProject(WorkflowJob)
pipelineJob.setDefinition(new CpsFlowDefinition("""
Expand Down Expand Up @@ -174,7 +175,7 @@ node {

def 'does not find build scans in pipeline logs when none have been published'() {
given:
gradleInstallationRule.gradleVersion = '5.6.4'
gradleInstallationRule.gradleVersion = '7.3.3'
gradleInstallationRule.addInstallation()
def pipelineJob = j.createProject(WorkflowJob)
pipelineJob.setDefinition(new CpsFlowDefinition("""
Expand Down Expand Up @@ -206,7 +207,7 @@ node {

def 'does not find build scans in pipeline logs when none have been published with withGradle'() {
given:
gradleInstallationRule.gradleVersion = '5.6.4'
gradleInstallationRule.gradleVersion = '7.3.3'
gradleInstallationRule.addInstallation()
def pipelineJob = j.createProject(WorkflowJob)
pipelineJob.setDefinition(new CpsFlowDefinition("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BuildScanInjectionGradleIntegrationTest extends BaseGradleIntegrationTest

private static final String MSG_INIT_SCRIPT_APPLIED = "Connection to Develocity: http://foo.com"

private static final List<String> GRADLE_VERSIONS = ['4.10.3', '5.6.4', '6.9.4', '7.6.4', '8.9']
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version removed as it fails both locally and on CI due to JDK 17 and Groovy version we use compatibility

private static final List<String> GRADLE_VERSIONS = ['4.10.3', '6.9.4', '7.6.4', '8.9']

private static final EnvVars EMPTY_ENV = new EnvVars()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package hudson.plugins.gradle.injection

import hudson.console.ConsoleNote
import hudson.model.Actionable
import hudson.plugins.gradle.BaseJenkinsIntegrationTest
import hudson.plugins.gradle.BuildScanAction
import spock.lang.Specification
import spock.lang.Subject

import java.nio.charset.StandardCharsets

class DevelocityExceptionLogProcessorTest extends Specification {
class DevelocityExceptionLogProcessorTest extends BaseJenkinsIntegrationTest {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching to Integration test to not depend on Jenkins implementation


private static final String GRADLE_PLUGIN_ERROR = "Internal error in Gradle Enterprise Gradle plugin: com.acme.FooBar"
private static final String MAVEN_EXTENSION_ERROR = "[ERROR] Internal error in Gradle Enterprise Maven extension: com.acme.FooBar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ class InjectionConfigTest extends BaseJenkinsIntegrationTest {
}

private static HtmlButton getAddButton(HtmlForm form, String label) {
def xpath = "//div[text() = '$label']/following-sibling::div[contains(@class, 'setting-main')]//span[contains(@class, 'repeatable-add')]//button[text() = 'Add']"
def xpath = "//div[text() = '$label']/following-sibling::div[contains(@class, 'setting-main')]//button[contains(@class, 'repeatable-add')]"

return form.getFirstByXPath(xpath)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MavenExtensionsDetectorTest extends Specification {
dir {
'.mvn' {
'extensions.xml'(generateExtensionsXml(
*(extensions.collect({ MavenCoordinates.parseCoordinates(it) }))))
*(extensions.collect { MavenCoordinates.parseCoordinates(it) })))
}
}

Expand Down Expand Up @@ -68,9 +68,9 @@ class MavenExtensionsDetectorTest extends Specification {
dir {
'.mvn' {
'extensions.xml'(
generateExtensionsXml(
MavenCoordinates.parseCoordinates('my:ext:1.0'),
MavenCoordinates.parseCoordinates('my:ext-ccud:1.0')))
generateExtensionsXml(
MavenCoordinates.parseCoordinates('my:ext:1.0'),
MavenCoordinates.parseCoordinates('my:ext-ccud:1.0')))
}
}

Expand Down
Loading