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

Missing symbols for JobDSL #92

Closed
jonesbusy opened this issue Oct 5, 2022 · 9 comments
Closed

Missing symbols for JobDSL #92

jonesbusy opened this issue Oct 5, 2022 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@jonesbusy
Copy link
Contributor

What feature do you want to see added?

Hi,

At the moment I was not able to find any Symbol to configure jobs and folder with custom icon.

Using jobDSL we must use configure block which is a bit painful

folder('my-folder') {
  description('my-folder')
  configure {
    it.remove(it / 'icon')
    it / 'icon'(class: 'jenkins.plugins.foldericon.IoniconFolderIcon', plugin: 'custom-folder-icon') {
      ionicon('bag-sharp')
    }
  }
}

Would be nice to have discoverable Symbol to configure the 'icon' field without relying on the configure block.

For example

folder('my-folder') {
  description('my-folder')
  icon {
     ionicon('bag-sharp')
  }
}

Regards,

Upstream changes

Maybe require some change on the branch-api plugin. I'm not sure

@jonesbusy jonesbusy added the enhancement New feature or request label Oct 5, 2022
@strangelookingnerd strangelookingnerd self-assigned this Oct 5, 2022
@strangelookingnerd
Copy link
Contributor

I'd like to implement this, however I have no idea where to start 😕
I feel like the first thing would be an upstream change to https://github.com/jenkinsci/job-dsl-plugin to have the icon configuration available? Maybe @daspilker can help?

@jonesbusy
Copy link
Contributor Author

Hi,

I think there is not need to change anything on JobDSL plugin.

Dynamic DSL should be used (https://github.com/jenkinsci/job-dsl-plugin/wiki/Dynamic-DSL)

I did some similar change on an other plugin : https://github.com/jenkinsci/github-checks-plugin/pull/289/files

So basically adding the correct Symbol should be enough.

Hope it helps

@strangelookingnerd
Copy link
Contributor

Taking your example for a build with JobDSL plugin:

folder('my-folder') {
  description('my-folder')
  icon {
     ionicon('bag-sharp')
  }
}

And adding the Symbol to the IoniconFolderIcon.java like in your PR:

@Extension
@Symbol("ionicon")
public static class DescriptorImpl extends FolderIconDescriptor {

Results in

Processing provided DSL script
ERROR: (script, line 2) No signature of method: javaposse.jobdsl.dsl.Folder.icon() is applicable for argument types: (script$_run_closure1$_closure2) values: [script$_run_closure1$_closure2@64f85f0]
Possible solutions: is(java.lang.Object), wait(), any(), find(), grep(), dump()
Finished: FAILURE

What am I missing here?

@jonesbusy
Copy link
Contributor Author

Hi,

I have the feeling the icon() comes from this plugin cloudbees-folder. Probably the symbol is missing there :

https://github.com/jenkinsci/cloudbees-folder-plugin/blob/daf4ca032c70095bf1476b04ed907f636b65adcf/src/main/java/com/cloudbees/hudson/plugins/folder/FolderIcon.java#L46

You can check on the test instance the job dsl viewer : <your instance>/plugin/job-dsl/api-viewer/index.html

I think is also important to test also with multibranchPipelineJob. For some reason I was not able to even use the configure block (not sure what is happening). Same configure block work for folder, but not multibranchPipelineJob

multibranchPipelineJob('my-multibranch') {
  description('my-multibranch')
  configure {
    it.remove(it / 'icon')
    it / 'icon'(class: 'jenkins.plugins.foldericon.IoniconFolderIcon', plugin: 'custom-folder-icon') {
      ionicon('bag-sharp')
    }
  }
}

@jonesbusy
Copy link
Contributor Author

I think the last issue I mentionned is related link to : #94

@strangelookingnerd
Copy link
Contributor

I have the feeling the icon() comes from this plugin cloudbees-folder. Probably the symbol is missing there :

https://github.com/jenkinsci/cloudbees-folder-plugin/blob/daf4ca032c70095bf1476b04ed907f636b65adcf/src/main/java/com/cloudbees/hudson/plugins/folder/FolderIcon.java#L46

I think so, too. I'll check if I can get it to work locally and create PR if required.

@strangelookingnerd
Copy link
Contributor

Adding @Symbol does not seem to have any effect, the same error remains.

Can anyone of @jenkinsci/job-dsl-plugin-developers give me a pointer were to start?

@strangelookingnerd
Copy link
Contributor

So I found that it seems to be required to adapt the job-dsl-plugin for this to work. I created jenkinsci/job-dsl-plugin#1258 for that.

If it gets merged, your use case should work OOTB like so:

folder('my-folder') {
  description('my-folder')
  icon {
    ioniconFolderIcon {
      ionicon('bag-sharp')
    } 
  }
}

@strangelookingnerd
Copy link
Contributor

Fixed once jenkinsci/job-dsl-plugin#1258 is merged. Whenever that will be 🤷🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants