gradle-plugin icon indicating copy to clipboard operation
gradle-plugin copied to clipboard

[JENKINS-44834]: finished "withGradle" step

Open soenkekueper opened this issue 6 years ago • 3 comments

I've just done some works on the initial fork by @alexbrjo to use the org.jenkins-ci.jpi gradle plugin. see https://github.com/jenkinsci/gradle-plugin/pull/52 for furhter information.

Along with some findbugs fixes and env var fix on windows this would be really nice to get gradle a little bit more included in the jenkins pipeline feature.

soenkekueper avatar Nov 22 '18 14:11 soenkekueper

@soenkekueper Thank you for the work you put in to add pipeline support for the Gradle plugin. I didn't really use the pipeline approach in a bigger project, so I am maybe not the best to give feedback for this PR.

Did you try that out on a real world project and does it work? What would I need to do to see the result? When this is merged, would it be possible to use Gradle more easily from a Jenkinsfile?

wolfs avatar Nov 26 '18 22:11 wolfs

Hey,

we are using gradle in a jenkins pipeline and had to do a lot of manually work to get it running. Than i've discovered the branch and pull request #52 by @alexbrjo and thought that would make it a bit easier. Due there was only little work to do, i've finished this request.

After this change, get a gradle running in an jenkinsfile is a little bit more easier - as you can use the gradle and jdk installation configured in jenkins, and - for usability and readability of the logs - the gradle console annotator is used. So you can see (as in regular builds or with ant) the tasks that have been executed and jump directly to them.

But there is one more problem which - i've also ran into when creating this pull request - you have to build your gradle command line manually and you have to care about platform specifics (as you can see in the tests you must always check if you are running on unix or windows and call sh or bat).

Due the logic of how to build the gradle command and to create an platform independent gradle step - i've afterwards started working on an simple "real" gradle step so you don't have to do this any more.

To wrap up: You are now able to run a pipline like this

node {
  withGradle(gradleName:'gradle-4.10') {
    if (isUnix()) {
  	sh 'gradle'
    } else {
      bat 'gradle build'
    }
  }
}

and you don't have to modify your PATH and JAVA_HOME (which in many cases causes other problems) and you have a little bit more readability of the logs.

But what im looking forward (and working on) is to have a real gradle step to write a jenkins file like this, which could aviod the problems above.

node {
    gradle gradleName: 'gradle-4.10', tasks: 'cleanTest build'
}

soenkekueper avatar Nov 27 '18 07:11 soenkekueper

What needs to be done to get this finished and merged?

I have one comment on the withGradle step. The property naming of gradleName and jdkName Why not just call it gradle and jdk? Then it would be more aligned with withMaven step naming of these same properties.

  withGradle(gradleName:'gradle-4.10', jdkName: 'jdk-11') {}
  withGradle(gradle:'gradle-4.10', jdk: 'jdk-11') {}
  withMaven(maven:'maven-3.5', jdk: 'jdk-11') {}

DJViking avatar Oct 14 '19 21:10 DJViking

I'll be closing the PR, given that there hasn't been any recent activity. Is the PR still interesting? If yes, please open a new one based on current main. Thank you!

wolfs avatar Oct 18 '22 09:10 wolfs