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

Cannot restrict a matrix build job to one node/label

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • matrix-project-plugin
    • None
    • Jenkins ver. 1.562
      Matrix Project Plugin 1.2

      Got the Matrix Job set this under Advanced: "Restrict where this project can be run" to "master"
      But when I run the Matrix only the first job runs on the Master - the rest run on any of the Slaves available

          [JENKINS-23459] Cannot restrict a matrix build job to one node/label

          Gilad Judes created issue -

          Hans Koster added a comment - - edited

          I am facing the same issue. I made some initialization jobs for slave nodes, which run when the slave starts. A Matrix job forces the installation of multiple JDKs and multiple Maven versions. After that it performs some testing to verify the proper installation of the tools. This Matrix job is triggered by another job that specifies the parameter build on same node for the Matrix job.

          Possible solutions:

          • All Matrix sub-jobs should inherit this setting by default. This setting can be overridden by choosing a value from the Slaves axis or label expression axis.
          • Maybe it is an idea to define also a virtual label same node in the Slaves axis or label expression axis.

          Hans Koster added a comment - - edited I am facing the same issue. I made some initialization jobs for slave nodes, which run when the slave starts. A Matrix job forces the installation of multiple JDKs and multiple Maven versions. After that it performs some testing to verify the proper installation of the tools. This Matrix job is triggered by another job that specifies the parameter build on same node for the Matrix job. Possible solutions: All Matrix sub-jobs should inherit this setting by default . This setting can be overridden by choosing a value from the Slaves axis or label expression axis. Maybe it is an idea to define also a virtual label same node in the Slaves axis or label expression axis.

          Oleg Nenashev added a comment -

          NodeLabel Parameter allows to restrict jobs in a such way

          Oleg Nenashev added a comment - NodeLabel Parameter allows to restrict jobs in a such way

          hbockelmann added a comment -

          I do agree that there are at least two solutions for this problem

          • NodeLabel parameter plugin with only one option/slave to be chosen
          • add slave axis with only one slave
            but both add additional complexity for maintaining the matrix job. The advanced option "Restrict where this project can be run" should IMHO do exactly this.

          hbockelmann added a comment - I do agree that there are at least two solutions for this problem NodeLabel parameter plugin with only one option/slave to be chosen add slave axis with only one slave but both add additional complexity for maintaining the matrix job. The advanced option "Restrict where this project can be run" should IMHO do exactly this.

          Damian Lezama added a comment -

          I agree that "Restrict where this project can be run" should be inherited by matrix jobs by default. It surprised me when it didn't work.

          A nice to have would be to be able to configure it per axis or per particular job. I can see how the job would override the axis, that would in turn override the main job value.

          Damian Lezama added a comment - I agree that "Restrict where this project can be run" should be inherited by matrix jobs by default. It surprised me when it didn't work. A nice to have would be to be able to configure it per axis or per particular job. I can see how the job would override the axis, that would in turn override the main job value.

          Reiner Wirtz added a comment -

          I have a problem using the following situation.

          I use a jenkins master and some virtual machines as slaves to start parallel tests.
          The virtual machines are configured to use a special test environment (database, WAS, JDK) in every vm.
          The test uses a matrix configuration to manage the different test configuration.

          At the start of the test every slave VM is resetted to a defined snapshot, to make sure the test conditions are always equal.
          After booting the VM, the build, selected for testing is installed on the jenkins slave VMs.
          If the Matrix jobs are started on a slave, the testresult is always failure due to the reset to the snapshot of the slave VM and the resultng network error.
          So I need the possibility to make sure, all the matrix jobs are started on jenkins master.

          Reiner Wirtz added a comment - I have a problem using the following situation. I use a jenkins master and some virtual machines as slaves to start parallel tests. The virtual machines are configured to use a special test environment (database, WAS, JDK) in every vm. The test uses a matrix configuration to manage the different test configuration. At the start of the test every slave VM is resetted to a defined snapshot, to make sure the test conditions are always equal. After booting the VM, the build, selected for testing is installed on the jenkins slave VMs. If the Matrix jobs are started on a slave, the testresult is always failure due to the reset to the snapshot of the slave VM and the resultng network error. So I need the possibility to make sure, all the matrix jobs are started on jenkins master.

          Reiner Wirtz added a comment -

          Hello,
          I think I solved my problem.
          I tried to restriced at first the execution of the matrix jobs bei a label expression in the advanced project settings.
          But that does not work.
          Now I use a simple groovy script to restrict the job to the master.
          The script is

          <pre>
          return "Master";
          </pre>

          Now all the matrix childs are executed on the jenkins master as I need in my test environment.

          Reiner Wirtz added a comment - Hello, I think I solved my problem. I tried to restriced at first the execution of the matrix jobs bei a label expression in the advanced project settings. But that does not work. Now I use a simple groovy script to restrict the job to the master. The script is <pre> return "Master"; </pre> Now all the matrix childs are executed on the jenkins master as I need in my test environment.

          Habeeb FKR added a comment -

          Hello @Reiner Writz

          Where have you put your script to force execution in the master ?

          Thanks

          Habeeb FKR added a comment - Hello @Reiner Writz Where have you put your script to force execution in the master ? Thanks

          Habeeb FKR added a comment -

          Hello @Reiner Writz

          Where have you put your script to force execution in the master ?

          Thanks

          Habeeb FKR added a comment - Hello @Reiner Writz Where have you put your script to force execution in the master ? Thanks

          Reiner Wirtz added a comment -

          In the first section of the multiconfiguration is an option to enter a groovy script to restrict where the job could be run.
          Activating this option opens an edit field for the groovy script.
          In this field I entered the mini groovy script: return "Master";
          This worked fine.

          Reiner Wirtz added a comment - In the first section of the multiconfiguration is an option to enter a groovy script to restrict where the job could be run. Activating this option opens an edit field for the groovy script. In this field I entered the mini groovy script: return "Master"; This worked fine.

            kohsuke Kohsuke Kawaguchi
            giladj Gilad Judes
            Votes:
            19 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated: