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

Can't restrict a pipeline job to agents to run on

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • pipeline
    • None

      Pipeline jobs should not be aware of the environment they run on. Stuff like agent nodes should not be specified in Jenkinsfile or the like. Agent nodes restriction should be configurable on pipeline jobs via UI.

          [JENKINS-39365] Can't restrict a pipeline job to agents to run on

          Oleg Nenashev added a comment -

          From what I see it goes against the vision of Jenkins Pipeline. If you want to get in UI, Job Restrictions allows doing it in Node configurations. If you need something more, please explain your use-case.

          Oleg Nenashev added a comment - From what I see it goes against the vision of Jenkins Pipeline. If you want to get in UI, Job Restrictions allows doing it in Node configurations. If you need something more, please explain your use-case.

          Colin Bennett added a comment -

          I think the description of this issue needs some more detail, with specific explanation of the problem that currently exists, since it's not obvious.

          Use semantic node labels to keep specifics of the Jenkins server/network "implementation" out of the project's build script (Jenkinsfile).  The Jenkinsfile should specify the semantic aspects of what it requires.  For instance, instead of a specific node name, describe the OS required.  Instead of describing a specific version of the OS, describe the features or limitations.

          Don't do this: node('mymachine002') { ... }
          Don't do this: node('linux002') { ... }
          Do this instead: node('linux && amd64 && database') { ... }

          Then you can control the specific nodes on which the pipeline will run by assigning appropriate node labels in the Jenkins system configuration.

          Perhaps it would be useful to allow configuring per-job parameters/environment variables in to the pipeline script from Jenkins however. This would be a general solution to many problems.

          Colin Bennett added a comment - I think the description of this issue needs some more detail, with specific explanation of the problem that currently exists, since it's not obvious. Use semantic node labels to keep specifics of the Jenkins server/network "implementation" out of the project's build script (Jenkinsfile).  The Jenkinsfile should specify the semantic aspects of what it requires.  For instance, instead of a specific node name, describe the OS required.  Instead of describing a specific version of the OS, describe the features or limitations. Don't do this: node('mymachine002') { ... } Don't do this: node('linux002') { ... } Do this instead: node('linux && amd64 && database') { ... } Then you can control the specific nodes on which the pipeline will run by assigning appropriate node labels in the Jenkins system configuration. Perhaps it would be useful to allow configuring per-job parameters/environment variables in to the pipeline script from Jenkins however. This would be a general solution to many problems.

          Steven Loomis added a comment -

          Seems like these are similar

          Steven Loomis added a comment - Seems like these are similar

          Andrew Bayer added a comment -

          Whether you choose to specify an explicit agent name or a label (as discussed in one of the comments above) is up to you - they work the same way, and we're not going to get rid of that.

          Andrew Bayer added a comment - Whether you choose to specify an explicit agent name or a label (as discussed in one of the comments above) is up to you - they work the same way, and we're not going to get rid of that.

            Unassigned Unassigned
            elnur Elnur Abdurrakhimov
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: