In an effort to balance speed with a satisfying stage view, we've taken steps to ensure that each stage runs on the same node. That way we dont have to stash/unstash too often because that is a big performance hit. For situations where we want to checkout source, configure, build and test it's fastest to just have this happen on the same workspace on the same node.

      The problem we've run into with this approach is that during that brief moment between a build and test stage for example, the node is available to all jobs and another job might grab it. We've attempted to work around this by getting clever with adding and removing node labels, but this creates all kinds of new bugs where labels don't get cleaned up or somehow a node ends up with labels from 2 different jobs at the same time.

      I thought I might have found something with https://github.com/jenkinsci/lockable-resources-plugin but that still feels like a manual process with creating "resources" that would apply to nodes and kind of faking that relationship by naming the resources the same as the nodes.

      The only way I can see at the moment to have the functionality and performance we're looking for is to combine all of the checkout+config+build+test into a single stage, but then we're losing much of what makes the pipeline workflow (and of course blue ocean) so useful.

      I would like to be able to grab an available node based on labels as I do now but have it stay reserved across stages until I explicitly say I'm done with it or the pipeline job is complete. If this can't be added as a new feature then any advice as to how to achieve this behavior with existing functionality would be much appreciated.

          [JENKINS-39119] Can't lock nodes between stages

          I may not understand your requirements correctly, but I think the "Lockable Resources" plugin (you are mentioning) should (now) allow you what you need/want according to:

          Because these "resources" are created automa(t|g)ically in pipelines?

          Reinhold Füreder added a comment - I may not understand your requirements correctly, but I think the "Lockable Resources" plugin (you are mentioning) should (now) allow you what you need/want according to: https://jenkins.io/blog/2016/10/16/stage-lock-milestone/ https://wiki.jenkins-ci.org/display/JENKINS/Lockable+Resources+Plugin Because these "resources" are created automa(t|g)ically in pipelines?

          Lucian Varlan added a comment -

          The "Lockable Resources" plugin is not a solution in the declarative pipeline since it cannot be used to include several stages.

          Lucian Varlan added a comment - The "Lockable Resources" plugin is not a solution in the declarative pipeline since it cannot be used to include several stages.

          Liam Newman added a comment -

          The work on JENKINS-46809 (see PR 227) may provide a solution for this using nested sequential stages.  This is being designed/discussed. 

          Liam Newman added a comment - The work on  JENKINS-46809  (see PR 227 ) may provide a solution for this using nested sequential stages.  This is being designed/discussed. 

          Andrew Bayer added a comment -

          Yup, marking this as a duplicate of JENKINS-46809, which is how this will be addressed in Declarative.

          Andrew Bayer added a comment - Yup, marking this as a duplicate of JENKINS-46809 , which is how this will be addressed in Declarative.

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            Unassigned Unassigned
            rainwaj Justin Rainwater
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: