When using the build user vars plugin in a pipeline the current required usage is:

      node {
          wrap([$class: 'BuildUser']) {
              // Do something with env.BUILD_USER* vars
          }
      }
      

      The 'node' is required here, because of how 'wrap' works. Because of this it is currently not possible to get the build user information outside the context of a node.

      Creating a custom Workflow step would solve this. Example:

      def buildUser = buildUserVars()
      // Do something with any of its properties:
      // - name
      // - firstName
      // - lastName
      // - userId
      // - email
      

      Or to keep it closer to how it currently works:

      buildUserVars {
        // Do something with env.BUILD_USER* vars
      }
      

      See https://issues.jenkins-ci.org/browse/JENKINS-30142 for a similar issue, which has been solved, for a different plugin.

          [JENKINS-44741] Build User Vars should not require node

          Mark Lagendijk created issue -
          Mark Lagendijk made changes -
          Description Original: When using the build user vars plugin in a pipeline the current required usage is:

           
          {code:java}
          node {
              wrap([$class: 'BuildUser']) {
                  // Do something with env.BUILD_USER* vars
              }
          }
          {code}
           

           

          The 'node' is required here, because of how 'wrap' works. See https://issues.jenkins-ci.org/browse/JENKINS-30142. Because of this it is currently not possible to get the build user information outside the context of a node.

          Creating a custom Workflow step would solve this. Example:
          {code:java}
          def buildUser = buildUserVars()
          // Do something with buildUser.BUILD_USER* vars
          {code}
          New: When using the build user vars plugin in a pipeline the current required usage is:

           
          {code:java}
          node {
              wrap([$class: 'BuildUser']) {
                  // Do something with env.BUILD_USER* vars
              }
          }
          {code}
           

           

          The 'node' is required here, because of how 'wrap' works. See https://issues.jenkins-ci.org/browse/JENKINS-30142. Because of this it is currently not possible to get the build user information outside the context of a node.

          Creating a custom Workflow step would solve this. Example:
          {code:java}
          def buildUser = buildUserVars()
          // Do something with any of its properties:
          // - name
          // - firstName
          // - lastName
          // - userId
          // - email
          {code}
          Or to keep it closer to how it currently works:

           
          {code:java}
          buildUserVars {
            // Do something with env.BUILD_USER* vars
          }
          {code}
          Mark Lagendijk made changes -
          Description Original: When using the build user vars plugin in a pipeline the current required usage is:

           
          {code:java}
          node {
              wrap([$class: 'BuildUser']) {
                  // Do something with env.BUILD_USER* vars
              }
          }
          {code}
           

           

          The 'node' is required here, because of how 'wrap' works. See https://issues.jenkins-ci.org/browse/JENKINS-30142. Because of this it is currently not possible to get the build user information outside the context of a node.

          Creating a custom Workflow step would solve this. Example:
          {code:java}
          def buildUser = buildUserVars()
          // Do something with any of its properties:
          // - name
          // - firstName
          // - lastName
          // - userId
          // - email
          {code}
          Or to keep it closer to how it currently works:

           
          {code:java}
          buildUserVars {
            // Do something with env.BUILD_USER* vars
          }
          {code}
          New: When using the build user vars plugin in a pipeline the current required usage is:
          {code:java}
          node {
              wrap([$class: 'BuildUser']) {
                  // Do something with env.BUILD_USER* vars
              }
          }
          {code}
          The 'node' is required here, because of how 'wrap' works. See https://issues.jenkins-ci.org/browse/JENKINS-30142. Because of this it is currently not possible to get the build user information outside the context of a node.

          Creating a custom Workflow step would solve this. Example:
          {code:java}
          def buildUser = buildUserVars()
          // Do something with any of its properties:
          // - name
          // - firstName
          // - lastName
          // - userId
          // - email
          {code}
          Or to keep it closer to how it currently works:
          {code:java}
          buildUserVars {
            // Do something with env.BUILD_USER* vars
          }
          {code}
          Mark Lagendijk made changes -
          Link New: This issue relates to JENKINS-30142 [ JENKINS-30142 ]
          Mark Lagendijk made changes -
          Description Original: When using the build user vars plugin in a pipeline the current required usage is:
          {code:java}
          node {
              wrap([$class: 'BuildUser']) {
                  // Do something with env.BUILD_USER* vars
              }
          }
          {code}
          The 'node' is required here, because of how 'wrap' works. See https://issues.jenkins-ci.org/browse/JENKINS-30142. Because of this it is currently not possible to get the build user information outside the context of a node.

          Creating a custom Workflow step would solve this. Example:
          {code:java}
          def buildUser = buildUserVars()
          // Do something with any of its properties:
          // - name
          // - firstName
          // - lastName
          // - userId
          // - email
          {code}
          Or to keep it closer to how it currently works:
          {code:java}
          buildUserVars {
            // Do something with env.BUILD_USER* vars
          }
          {code}
          New: When using the build user vars plugin in a pipeline the current required usage is:
          {code:java}
          node {
              wrap([$class: 'BuildUser']) {
                  // Do something with env.BUILD_USER* vars
              }
          }
          {code}
          The 'node' is required here, because of how 'wrap' works. Because of this it is currently not possible to get the build user information outside the context of a node.

          Creating a custom Workflow step would solve this. Example:
          {code:java}
          def buildUser = buildUserVars()
          // Do something with any of its properties:
          // - name
          // - firstName
          // - lastName
          // - userId
          // - email
          {code}
          Or to keep it closer to how it currently works:
          {code:java}
          buildUserVars {
            // Do something with env.BUILD_USER* vars
          }
          {code}

          See https://issues.jenkins-ci.org/browse/JENKINS-30142 for a similar issue, which has been solved, for a different plugin.
          Jakub Bochenski made changes -
          Link New: This issue relates to JENKINS-44771 [ JENKINS-44771 ]

          Sorin Sbarnea added a comment -

          Any updates on this? It would really be useful to use this without putting it inside node block.

          Sorin Sbarnea added a comment - Any updates on this? It would really be useful to use this without putting it inside node block.

          Shannon Kerr added a comment -

          Agree.  Wish I didn't have to wrap this with node.

           

          Shannon Kerr added a comment - Agree.  Wish I didn't have to wrap this with node.  

          Sunil Chopra added a comment -

          Agree.  This not being a feature is very puzzling and makes the plugin hard to use.  The fact that the plugin is necessary at all is weird.  The fact that the plugin then goes further in requiring a node makes the situation super frustrating.

          For what it's worth, I was able to put together a one-ish line of Groovy that effectively "liberates" the needed information.  But this is highly confusing and increases technical debt in our pipelines. 

          node {
            wrap([$class: 'BuildUser']) { env.BUILD_USER_ID = env.BUILD_USER_ID  } 
          }
          
          echo env.BUILD_USER_ID

          Sunil Chopra added a comment - Agree.  This not being a feature is very puzzling and makes the plugin hard to use.  The fact that the plugin is necessary at all is weird.  The fact that the plugin then goes further in requiring a node makes the situation super frustrating. For what it's worth, I was able to put together a one-ish line of Groovy that effectively "liberates" the needed information.  But this is highly confusing and increases technical debt in our pipelines.  node { wrap([$class: 'BuildUser' ]) { env.BUILD_USER_ID = env.BUILD_USER_ID } } echo env.BUILD_USER_ID

          Isela Pintor added a comment -

          Agree.  This would work much better if no node wrapper was needed.

          Isela Pintor added a comment - Agree.  This would work much better if no node wrapper was needed.

            zedasvacas Fábio Silva
            markl_lagendijk Mark Lagendijk
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: