• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • Jenkins 2.243

      AbstractProjectDescriptor.doAutoCompleteLabel has a complex implementation including AutoCompleteSeeder that ought to be made available as an API in Label.

      Similarly doCheckLabel should be available as an API.

      For use from Workflow (ExecutorStep.DescriptorImpl), LabelValidator has to be generalized to handle any Job (probably meaning the nested class in AbstractProject should be deprecated and it should be moved to a top-level class). This is assuming that there are some meaningful implementations for other job types; until INFRA-180 is fixed this is tricky to verify but https://github.com/search?type=Code&q=user%3Ajenkinsci+LabelValidator turns up no hits. (SecurityTokensNodeProperty in cloudbees-folders-plus could add one, perhaps.)

          [JENKINS-26097] AutoCompletionCandidates for Label

          Jesse Glick created issue -
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 160087 ] New: JNJira + In-Review [ 180249 ]
          Andrew Bayer made changes -
          Labels Original: api workflow New: api pipeline workflow
          Andrew Bayer made changes -
          Labels Original: api pipeline workflow New: api pipeline

          Just ran into this.

          For validation, there is a static method available; that might need further generalization, but my use is outside a job context anyway (label expression for a tool installer).

          But there is no equivalent for auto-completion. The code is non-trivial enough no to just duplicate it (even leaving out that duplication is bad), and because I don't need it in a project context, I can't use @AncestorInPath to get at the descriptor instance either. So for now I seem to be stuck with

              @SuppressWarnings("unused")
              public AutoCompletionCandidates doAutoCompleteLabel(@QueryParameter String value) {
                return new FreeStyleProject.DescriptorImpl().doAutoCompleteLabel(value);
              }
          

          which is... suboptimal to say the least.

          I'll look into a PR with an API proposal (initially low-ambition, so not attempting to generalize for Job yet).

          Tim Van Holder added a comment - Just ran into this. For validation, there is a static method available; that might need further generalization, but my use is outside a job context anyway (label expression for a tool installer). But there is no equivalent for auto-completion. The code is non-trivial enough no to just duplicate it (even leaving out that duplication is bad), and because I don't need it in a project context, I can't use @AncestorInPath to get at the descriptor instance either. So for now I seem to be stuck with @SuppressWarnings( "unused" ) public AutoCompletionCandidates doAutoCompleteLabel(@QueryParameter String value) { return new FreeStyleProject.DescriptorImpl().doAutoCompleteLabel(value); } which is... suboptimal to say the least. I'll look into a PR with an API proposal (initially low-ambition, so not attempting to generalize for Job yet).
          Tim Van Holder made changes -
          Assignee New: Tim Van Holder [ zastai ]

          Draft PR created.

          Tim Van Holder added a comment - Draft PR created.
          Tim Van Holder made changes -
          Remote Link New: This issue links to "Draft PR (jenkins/4774) (Web Link)" [ 25002 ]
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Oleg Nenashev made changes -
          Released As New: Jenkins 2.243
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]

            zastai Tim Van Holder
            jglick Jesse Glick
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: