gradle(...) step for workflow is desirable, so that its output gets annotated to show the list of tasks that have been executed.

          [JENKINS-27393] Workflow step for Gradle invocation

          Alex Yu added a comment -

          it planed to implement?

          Alex Yu added a comment - it planed to implement?

          Sam Sieber added a comment -

          orrc Arbitrary shell script stuff is supported but unfortunately not very good for gradle - when using gradlew from the shell it grabs the systems java, not what's configured in Jenkins, and I've run into an error where it can't find the correct gradle from /var/empty/.gradle, a mysterious error.

          So, I guess what I'm saying is that actual integration would still be very nice and a step up.

          Sam Sieber added a comment - orrc Arbitrary shell script stuff is supported but unfortunately not very good for gradle - when using gradlew from the shell it grabs the systems java, not what's configured in Jenkins, and I've run into an error where it can't find the correct gradle from /var/empty/.gradle, a mysterious error. So, I guess what I'm saying is that actual integration would still be very nice and a step up.

          Robert Gacki added a comment -

          Following snippet works for us:

          def javaEnv() {
            def javaHome = tool 'Java 8'
            ["PATH=${env.PATH}:${javaHome}/bin", "JAVA_HOME=${javaHome}"]
          }
          
          node {
            withEnv(javaEnv()) {
              sh './gradlew clean assemble -x test'
            }
          }
          

          +1 For native plugin support

          Robert Gacki added a comment - Following snippet works for us: def javaEnv() { def javaHome = tool 'Java 8' [ "PATH=${env.PATH}:${javaHome}/bin" , "JAVA_HOME=${javaHome}" ] } node { withEnv(javaEnv()) { sh './gradlew clean assemble -x test' } } +1 For native plugin support

          Jesse Glick added a comment -

          There is not currently an API that would allow the Gradle builder to be trivially operated in a Pipeline build, since code using Proc cannot survive Jenkins restarts or even agent disconnections. JENKINS-26055 proposes a supported API allowing a new Step to be defined that runs some Gradle executable as a durable task, while maintaining feature parity with the traditional builder:

          • creating a customized command line
          • predefining environment variables like JAVA_HOME based on tool selections
          • applying GradleConsoleAnnotator

          Jesse Glick added a comment - There is not currently an API that would allow the Gradle builder to be trivially operated in a Pipeline build, since code using Proc cannot survive Jenkins restarts or even agent disconnections. JENKINS-26055 proposes a supported API allowing a new Step to be defined that runs some Gradle executable as a durable task, while maintaining feature parity with the traditional builder: creating a customized command line predefining environment variables like JAVA_HOME based on tool selections applying GradleConsoleAnnotator

          Jesse Glick added a comment -

          And yes the first two requirements can be met with a library function that takes various parameters similar to the Gradle build step but ultimately runs withEnv and sh and tool.

          Jesse Glick added a comment - And yes the first two requirements can be met with a library function that takes various parameters similar to the Gradle build step but ultimately runs withEnv and sh and tool .

          Douglas Paul added a comment -

          Having a gradle step that survives restarts/disconnections would be great eventually, but does that really need to hold up Gradle becoming a first-class build step? The manual tool/withEnv/sh approach is clunky, and I'm really missing the GradleConsoleAnnotator.

          Douglas Paul added a comment - Having a gradle step that survives restarts/disconnections would be great eventually, but does that really need to hold up Gradle becoming a first-class build step? The manual tool / withEnv / sh approach is clunky, and I'm really missing the GradleConsoleAnnotator .

          Lorant Onodi added a comment -

          I have to agree with douglaswpaul, I would really like to use gradle plugin in the my pipeline scripts instead of the sh approach. Also, as far as I am aware, the JENKINS-26055 is a "Won't Do". So what's up now?

          Lorant Onodi added a comment - I have to agree with douglaswpaul , I would really like to use gradle plugin in the my pipeline scripts instead of the sh approach. Also, as far as I am aware, the JENKINS-26055  is a "Won't Do". So what's up now?

          Stefan Wolf added a comment -

          lorantonodi: What would you expect to be supported as part of the pipeline DSL? What are your use cases?

          I would look into implementing better support for pipeline but first I would like to know what should be supported and what the DSL would look like.

          Stefan Wolf added a comment - lorantonodi : What would you expect to be supported as part of the pipeline DSL? What are your use cases? I would look into implementing better support for pipeline but first I would like to know what should be supported and what the DSL would look like.

          Alex Johnson added a comment - - edited

          This is being considered as part of the Important Pipeline Compatibility Epic. Here are the tasks to get this plugin to a basic level (not a durable task) of pipeline compatibility:

          • Refactor to use Pipeline compatible APIs
          • Add withGradle() builder step as an improved workaround for a bash shell step
            • Would provide GradleConsoleAnnotator and would use environment vars
          • Test that pipeline can run and Gradle console output can be annotated
          • Manual test to confirm step runs in pipeline with console annotator

          Alex Johnson added a comment - - edited This is being considered as part of the  Important Pipeline Compatibility Epic . Here are the tasks to get this plugin to a basic level (not a durable task) of pipeline compatibility: Refactor to use Pipeline compatible APIs Add withGradle() builder step as an improved workaround for a bash shell step Would provide GradleConsoleAnnotator and would use environment vars Test that pipeline can run and Gradle console output can be annotated Manual test to confirm step runs in pipeline with console annotator

          Ryan Campbell added a comment -

          We are splitting the withGradle and ConsoleAnnotator into JENKINS-44834 and leaving this issue targetted at the original request for a gradle step. We believe that JENKINS-44834 will address the core use-cases which gradle users expect from gradle integration with pipeline.

          Ryan Campbell added a comment - We are splitting the withGradle and ConsoleAnnotator into  JENKINS-44834 and leaving this issue targetted at the original request for a gradle step. We believe that  JENKINS-44834 will address the core use-cases which gradle users expect from gradle integration with pipeline.

            gbois Gregory Boissinot
            kohsuke Kohsuke Kawaguchi
            Votes:
            45 Vote for this issue
            Watchers:
            55 Start watching this issue

              Created:
              Updated: