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

Show agent/node where the build has beed executed in pipelines (blue-ocean / traditional)

      I'd like to see the slaves where a build has been executed without having to check the logs.

      Not sure if this is already possible, but since I don't know how to, I have to go to Build > Logs and look for agent/slave name to identify in which slave the build was executed

      If something has to be done, I'd like to see it on Blue Ocean UI and in traditional pipeline, on each step. It'll be also helpful in build view page.

      Please close this issue if it's duplicated or does not apply.

      Thanks!

          [JENKINS-47138] Show agent/node where the build has beed executed in pipelines (blue-ocean / traditional)

          Tim Black added a comment - - edited

          I agree this feature is highly desirable. When everything is working perfectly, it is never necessary to see what agent a build ran on. However, the rest of the time, it is critical to be able to quickly determine which agent it ran on so the workspace can be perused by sshing onto the agent machine.

          I haven't been able to find any plugins that can provide this information on build pages, so what I've done is to add the following (scripted, wrapped in declarative) pipeline code to put the agent name in the build description:

           

          stage("Set Build Description to Indicate Agent Used") {
              // It is useful to see agent name in an obvious location (without having to scrape the console).
              // Jenkins is not capable of doing this currently so we do it in Pipeline: https://issues.jenkins-ci.org/browse/JENKINS-47138
              steps {
                  script {
                      currentBuild.description = "Building on ${env.NODE_NAME}"
                  }
              }
          }
          

          Tim Black added a comment - - edited I agree this feature is highly desirable. When everything is working perfectly , it is never necessary to see what agent a build ran on. However, the rest of the time , it is critical to be able to quickly determine which agent it ran on so the workspace can be perused by sshing onto the agent machine. I haven't been able to find any plugins that can provide this information on build pages, so what I've done is to add the following (scripted, wrapped in declarative) pipeline code to put the agent name in the build description:   stage( "Set Build Description to Indicate Agent Used" ) { // It is useful to see agent name in an obvious location (without having to scrape the console). // Jenkins is not capable of doing this currently so we do it in Pipeline: https://issues.jenkins-ci.org/browse/JENKINS-47138 steps { script { currentBuild.description = "Building on ${env.NODE_NAME}" } } }

          sparrowt added a comment -

          The above works well when your entire build only runs on 1 node - when this is not the case (e.g. using multiple node blocks in scripted pipeline, or within a script block in declarative) it seems currently the only option is to start sprinkling these within each of your node blocks

          echo "Running on ${env.NODE_NAME}"
          

          c.f. https://stackoverflow.com/questions/64823562/

          Worth also noting you may have stage and node either way round and the echo should be within both in order to show up within the stage's steps and to get the correct node name

          • stage within node
            node('foolabel') {
                stage('mystage') {
                    echo "Running on ${env.NODE_NAME}"
                    ....
                }
            }
            
          • node within stage
            stage('mystage') {
                node('foolabel') {
                    echo "Running on ${env.NODE_NAME}"
                    ....
                }
            }
            

          sparrowt added a comment - The above works well when your entire build only runs on 1 node - when this is not the case (e.g. using multiple node blocks in scripted pipeline, or within a script block in declarative) it seems currently the only option is to start sprinkling these within each of your node blocks echo "Running on ${env.NODE_NAME}" c.f. https://stackoverflow.com/questions/64823562/ Worth also noting you may have stage and node either way round and the echo should be within both in order to show up within the stage's steps and to get the correct node name stage within node node('foolabel') { stage('mystage') { echo "Running on ${env.NODE_NAME}" .... } } node within stage stage('mystage') { node('foolabel') { echo "Running on ${env.NODE_NAME}" .... } }

            Unassigned Unassigned
            mdelapenya Manuel de la Peña
            Votes:
            14 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: