• 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

          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).

          Draft PR created.

          Tim Van Holder added a comment - Draft PR created.

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

              Created:
              Updated:
              Resolved: