jenkinsci / templating-engine-plugin

create tool-agnostic, templated pipelines to be shared by multiple teams
https://jenkinsci.github.io/templating-engine-plugin/latest/
Apache License 2.0
171 stars 58 forks source link

[Bug]: Can't build JTE library plugin with Java 22 and Gradle 8.8 for Jenkins 2.452.1 #338

Closed shree665 closed 5 months ago

shree665 commented 5 months ago

Jenkins Version

2.452.1

JTE Version

2.5.3

Bug Description

I am trying to create a plugin with our JTE library. I am running in to weirded dependency error. I am using Java 22, and gradle 8.8. I thought i updated all the required version of plugins but i keep getting following error whenever i try to build plugin using ./gradlew jte. I do not know where the structs dependency is coming from. I even tried to exclude some dependencies, but it seems it includes those no matter. Any pointers would help us since we are going to be running minimum 100s of pipeline simultaneously and we can't keep going to repo to download each libraries.

Relevant log output

em-devops-jenkins-library % ./gradlew jte                      
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':jpi'.
> Could not resolve all dependencies for configuration ':runtimeClasspathJenkins'.
   > There was an error while evaluating a component metadata rule for org.jenkins-ci.plugins.workflow:workflow-step-api:622.vb_8e7c15b_c95a_.
      > Could not get unknown property 'originalMetadata' for org.jenkins-ci.plugins:structs:1.23 of type org.gradle.api.internal.artifacts.repositories.resolver.DirectDependencyMetadataAdapter.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

Steps to Reproduce

Add following build.gradle

plugins{
  // used to packate these libraries as a jenkins plugin
  // see: https://github.com/jenkinsci/gradle-jte-plugin/blob/main/README.md
  id "io.jenkins.jte" version "0.2.0"
  id 'org.jenkins-ci.jpi' version '0.43.0'
  id 'groovy'
  id 'jacoco'
}

version = "0.0.1"

// an artifact required by how Jenkins Spock is hard-coded
project.buildDir = "target" 

// packaging info
jenkinsPlugin{
  jenkinsVersion = "2.452.1"
  shortName = "emmett-library"
  // will be the value in the drop down in Jenkins UI
  displayName = "Emmett JTE Library"
}

repositories {
    mavenCentral()
    maven { url "https://repo.jenkins-ci.org/public/" }
    maven { url "https://repo.jenkins-ci.org/releases" }
    maven { url "https://repo.maven.apache.org/maven2" }
}

// determine test files
def tests = [ "resources/test" ]
fileTree("libraries").visit{ FileVisitDetails details ->
  if(details.file.isDirectory() && details.file.path ==~ ".*libraries/.*/test"){
    println details.file.path
    tests << details.file.path
  }
}

// don't compile libraries
compileGroovy.enabled = false 

sourceSets{
  test{
    output.resourcesDir("${buildDir}/test-classes")
    groovy{
      srcDirs = tests
    }
    resources{
      srcDirs = [ "libraries" ]
    }
  }
}

// library dependencies
dependencies {
  // unit test framework deps
  implementation group: 'org.slf4j', name: 'slf4j-api', version:'1.7.25'
  runtimeOnly group: 'ch.qos.logback', name: 'logback-core', version:'1.2.3'
  runtimeOnly group: 'ch.qos.logback', name: 'logback-classic', version:'1.2.3'
  runtimeOnly group: 'org.slf4j', name: 'jcl-over-slf4j', version:'1.7.25'
  runtimeOnly group: 'org.slf4j', name: 'log4j-over-slf4j', version:'1.7.25'
  implementation group: 'com.homeaway.devtools.jenkins', name: 'jenkins-spock', version:'2.1.2'
  implementation group: 'javax.servlet', name: 'javax.servlet-api', version:'3.1.0'
  implementation group: 'junit', name: 'junit', version:'4.12'
  implementation group: 'org.jenkins-ci.main', name: 'jenkins-core', version:'2.452.1', {
    exclude group: 'com.ibm.icu', module: 'icu4j'
  }
  testImplementation group: 'org.gitlab4j', name: 'gitlab4j-api', version: '4.15.6'
  testImplementation group: 'org.jenkins-ci', name: 'symbol-annotation', version:'1.10'
  implementation group: 'org.codehaus.groovy', name: 'groovy-all', version:'2.4.11'
  testImplementation group: 'org.spockframework', name: 'spock-core', version:'1.1-groovy-2.4'
  // our plugin deps
  //implementation group: "org.jenkins-ci.plugins", name: "structs", version: "324.va_f5d6774f3a_d"
  implementation(group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-step-api', version: '622.vb_8e7c15b_c95a_') {
    exclude(module: 'structs')
  }
  implementation group: "org.jenkins-ci.plugins.workflow", name: "workflow-cps", version: "3859.v7f65cc865019"
  implementation group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-scm-step', version:'2.13'
  implementation group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-durable-task-step', version:'1128.v8c259d125340'
  implementation group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-multibranch', version: '707.v71c3f0a_6ccdb_'
  implementation group: "org.jenkins-ci.plugins.workflow", name: "workflow-basic-steps", version: '961.vfe95552883f8'
  implementation group: 'org.jenkins-ci.plugins', name: 'pipeline-stage-step', version:'2.4'
  implementation group: 'org.jenkins-ci.plugins', name: 'ssh-agent', version:'1.24.1'
  implementation group: "org.jenkins-ci.plugins", name: "pipeline-utility-steps", version: '2.15.1'
  implementation group: "org.jenkins-ci.plugins", name: "credentials-binding", version: "523.525.vb_72269281873"
  implementation group: "org.jenkins-ci.plugins", name: "docker-workflow", version: "1.28"
  implementation group: "org.jenkins-ci.plugins", name: "sonar", version: "2.14"
  implementation group: 'org.jenkins-ci.plugins.workflow', name: 'workflow-api', version: '2.40'
  implementation group: 'org.jenkinsci.plugins', name: 'pipeline-model-definition', version: '1.9.3'

  //our plugin
  implementation group: 'org.jenkins-ci.plugins', name: "templating-engine", version: "2.5.3"
 }

test{
  jacoco{
    classDumpDir = file("$buildDir/jacoco/classpathdumps")
  }
  finalizedBy jacocoTestReport
}
jacocoTestReport{
  doFirst{
    // delete non-library class files 
    fileTree("$buildDir/jacoco/classpathdumps").exclude("libraries").visit{ FileVisitDetails deets ->
      delete deets.file
    }
    // delete Test files 
    fileTree("$buildDir/jacoco/classpathdumps/libraries").visit{ FileVisitDetails deets ->
      if(deets.file.name.contains("Spec")){
        delete deets.file
      }
    }
  }
  additionalSourceDirs files(".")
  additionalClassDirs files("$buildDir/jacoco/classpathdumps")
  reports{
    html {
      enabled true
    }
  }
}

tasks.register('printVersion'){
  doLast{
    println version
  }
}

My end goal is to build this in air gap environment. I really want to build without above dependencies. We have above dependencies in our Jenkins already.

cokieffebah commented 5 months ago

asked try this line in your plugins: id 'org.jenkins-ci.jpi' version '0.50.0-rc.3'

shree665 commented 5 months ago

Updating org.jenkins-ci.jpi to 0.50.0-rc.3 version fixed the issue.