Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-34988

this.binding.jenkinsProject not returning project of current build

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • active-choices-plugin

      Using active choice plugin, active choices reactive reference paramter with a scriptler script.

      We are trying to get the current build's SCM repo in order to pull the latest tags. We use

      scm = this.binding.jenkinsProject.scm;
      if (scm instanceof hudson.plugins.git.GitSCM) {
        for (RemoteConfig cfg : scm.getRepositories()) {
          for (URIish uri : cfg.getURIs()) {
            repo = uri.toString();
          }
        }
      }
      println repo
      ...
      

      It should be noted that both

      this.binding.jenkinsProject.scm
      

      and

      jenkinsProject.scm
      

      produce the same results.

      To get the current build and get the repo url. This seems to only return the project that was last saved in the UI, regardless of which job is being run.

      Steps to reproduce:

      1. Create Job A. Include the reactive reference parameter and use the script with the above code. Save it. Build with parameters. In catalina.out on the master Jenkins node, we see the correct repo is being used.

      2. Create Job B. Include the reactive reference parameter and use the script above. Save it.

      3. In Job A: Build with parameters. catalina.out shows the repo from Job B.

      4. Save Job A. Build with parameters. catalina.out shows the repo from Job A.

      5. Create Job C. Do not include reactive reference parameter. Save.

      6. Job A: Build with parameters. catalina.out shows repo from Job A (last job saved in the UI that uses reactive reference parameter.

      If Job X uses the reactive reference parameter, when Job X is saved, any other jobs that also use the reactive reference parameter will return Job X for this.binding.jenkinsProject, or just jenkinsProject (without prepending this.binding)

      Unless I am incorrect in my understanding of how this functions, I would expect

      this.binding.jenkinsProject
      

      to return the current job, not the last one saved in the UI.

      I did see https://issues.jenkins-ci.org/browse/JENKINS-29476 which appears to be related, but not quite the same. jenkinsProject is available after a fresh Jenkins start (as noted in the resolution of that issue), but it just isn't using the project for the currently running build.

      Full script is attached for reference.

            kinow Bruno P. Kinoshita
            erbrecht Travis Collins
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: