active-choices-plugin icon indicating copy to clipboard operation
active-choices-plugin copied to clipboard

WIP: [JENKINS-63284] Add initial Pipeline job support for Groovy properties

Open M-r-A opened this issue 4 years ago • 8 comments

I want to add support for Pipeline job for Groovy script properties.

Currently, the plugin does not fully work with the Pipeline job: it uses classes that are specific only for the Freestyle job for getting extra data to inject to Groovy binding.

I changed plugin code to deal with Job/Run classes and added a test that demonstrates the result.

With these changes, users will be able to use jenkinsProject Groovy property with the Pipeline job.

Related issues: JENKINS-63284, JENKINS-65235, JENKINS-53554. Related guide: Writing Pipeline-Compatible Plugins

  • [x] Make sure you are opening from a topic/feature/bugfix branch (right side) and not your master branch!
  • [x] Ensure that the pull request title represents the desired changelog entry
  • [x] Please describe what you did
  • [x] Link to relevant issues in GitHub or Jira
  • [x] Link to relevant pull requests, esp. upstream and downstream changes
  • [x] Ensure you have provided tests - that demonstrates feature works or fixes the issue

M-r-A avatar Apr 12 '21 11:04 M-r-A

Is there a reason why this was never finished ?

c4sh avatar Feb 01 '22 08:02 c4sh

Hey @M-r-A @kinow would it be possible to finalize this PR? 🙏 This feature would be amazing to have

jan-stoltman-bolt avatar Mar 25 '22 07:03 jan-stoltman-bolt

Hey @M-r-A @kinow would it be possible to finalize this PR? pray This feature would be amazing to have

Sorry, a bit strapped for time (life, work, being sponsored to work on other OSS projects, etc.)

Maybe someone could test the current PR with pipelines, and report whether it's working or not? That could help myself or another dev when re-starting the work on this code.

Cheers Bruno

kinow avatar Mar 25 '22 09:03 kinow

Hi @kinow, I merged the PR to the master branch in a local clone and built the plugin. After installing the plugin on Jenkins, I tried to define a ChoiceParameter (also tried with lower-case and camel-case) in a declarative pipeline's "parameters" block but got the following error which shows that only specific types of parameters are allowed:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 286: Invalid parameter type "ChoiceParameter". Valid parameter types: [booleanParam, choice, credentials, extendedChoice, file, text, password, run, string] @ line 286, column 5.
       ChoiceParameter name: 'ENVIRONMENT'
       ^

Maybe additional development is required in other plugins to support this feature. Please let me know if my approach with the "parameters" block was the indented one or if should test in a different way.

Thanks, Dimitris

dimmel82 avatar Aug 17 '22 11:08 dimmel82

Thanks a lot for testing and reporting @dimmel82!

kinow avatar Aug 17 '22 23:08 kinow

Is there an update? I have been looking for this feature for a long time

JinPengGeng avatar Jun 01 '23 06:06 JinPengGeng

Pinging for updates

asetty avatar Jul 27 '23 05:07 asetty

Hi @kinow, I merged the PR to the master branch in a local clone and built the plugin. After installing the plugin on Jenkins, I tried to define a ChoiceParameter (also tried with lower-case and camel-case) in a declarative pipeline's "parameters" block but got the following error which shows that only specific types of parameters are allowed:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 286: Invalid parameter type "ChoiceParameter". Valid parameter types: [booleanParam, choice, credentials, extendedChoice, file, text, password, run, string] @ line 286, column 5.
       ChoiceParameter name: 'ENVIRONMENT'
       ^

Maybe additional development is required in other plugins to support this feature. Please let me know if my approach with the "parameters" block was the indented one or if should test in a different way.

Thanks, Dimitris

This PR is only for having access to Jenkins API for pipeline job types from groovy code used in the parameter's script. Definition of the active-choices parameters in declarative way are not implemented but sure it would be an amazing feature to have. We used mixed scripted/declarative pipeline to define this type of parameters. Is not so cool but it works.

mvanini avatar Dec 17 '23 10:12 mvanini