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

credentialsId shows different in `Jenkins.instance.nodes` and `Jenkins.instance.computers`

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Critical Critical
    • core, ssh-slaves-plugin

      I've been updated credential ID in the SSH Agent ( hudson.plugins.sshslaves.SSHLauncher ), when I using script to check the credentialsId status, find out the jenkins.model.Jenkins.instance.nodes works as I saw in configure page, however, the jenkins.model.Jenkins.instance.computers still shows the legacy ( previous ) credentialsId .

       

      groovy script for list nodes credentials:

      computer.getNode():

      Jenkins.instance.computers.findAll { computer ->
        ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
        computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
      }.each { computer ->
        println computer.node.launcher?.credentialsId?.toString()     // shows updated, same with configuration page
        println computer.launcher?.credentialsId?.toString()          // issue: shows the legacy credentialsId
      }
      

       
      node.toComputer():

      Jenkins.instance.nodes.findAll { node ->
        ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
        node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
      }.each { node ->
        println node.launcher?.credentialsId?.toString() + ' : ' + node.getClass()
        println node.toComputer().launcher?.credentialsId?.toString() + ' : ' + node.toComputer().getClass()
      }
      

      screenshot:

      BTW, here is the groovy script to update nodes credential:

      import jenkins.model.Jenkins
      import hudson.plugins.sshslaves.SSHLauncher
      import hudson.slaves.ComputerLauncher
      
      String newCredId = 'GIT_SSH_CREDENTIAL'
      
      Jenkins.instance.nodes.findAll { node ->
        ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
        node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
      }.each { node ->
        ComputerLauncher launcher = node.launcher
        SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
        node.setLauncher( newLauncher )
        node.save()
        println ">> ${node.name} DONE <<"
      }
      

          [JENKINS-72716] credentialsId shows different in `Jenkins.instance.nodes` and `Jenkins.instance.computers`

          Marslo Jiao created issue -
          Marslo Jiao made changes -
          Description Original: I've been updated credential ID in the SSH Agent ( {{hudson.plugins.sshslaves.SSHLauncher}} ), when I using script to check the {{credentialsId}} status, find out the {{jenkins.model.Jenkins.instance.nodes}} works as I saw in configure page, however, the {{jenkins.model.Jenkins.instance.computers}} still shows the legacy ( previous ) {{credentialsId}} .

           

          groovy script for list nodes credentials:
          {code:groovy}
          Jenkins.instance.computers.findAll { computer ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
            computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { computer ->
            println computer.node.launcher?.credentialsId?.toString()
            println computer.launcher?.credentialsId?.toString()
          }

          "DONE"
          {code}
           

          screenshot:

          !image-2024-02-14-22-14-26-887.png|height=444!


          BTW, here is the groovy script to update nodes credential:
          {code:groovy}
          import jenkins.model.Jenkins
          import hudson.plugins.sshslaves.SSHLauncher
          import hudson.slaves.ComputerLauncher

          String newCredId = 'GIT_SSH_CREDENTIAL'

          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            ComputerLauncher launcher = node.launcher
            SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
            node.setLauncher( newLauncher )
            node.save()
            println ">> ${node.name} DONE <<"
          }
          {code}
          New: I've been updated credential ID in the SSH Agent ( {{hudson.plugins.sshslaves.SSHLauncher}} ), when I using script to check the {{credentialsId}} status, find out the {{jenkins.model.Jenkins.instance.nodes}} works as I saw in configure page, however, the {{jenkins.model.Jenkins.instance.computers}} still shows the legacy ( previous ) {{credentialsId}} .

           

          groovy script for list nodes credentials:
          {code:groovy}
          Jenkins.instance.computers.findAll { computer ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
            computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { computer ->
            println computer.node.launcher?.credentialsId?.toString() // shows updated, same with configuration page
            println computer.launcher?.credentialsId?.toString() // issue: shows the legacy credentialsId
          }

          "DONE"
          {code}
           

          screenshot:

          !image-2024-02-14-22-14-26-887.png|height=444!

          BTW, here is the groovy script to update nodes credential:
          {code:groovy}
          import jenkins.model.Jenkins
          import hudson.plugins.sshslaves.SSHLauncher
          import hudson.slaves.ComputerLauncher

          String newCredId = 'GIT_SSH_CREDENTIAL'

          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            ComputerLauncher launcher = node.launcher
            SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
            node.setLauncher( newLauncher )
            node.save()
            println ">> ${node.name} DONE <<"
          }
          {code}
          Marslo Jiao made changes -
          Description Original: I've been updated credential ID in the SSH Agent ( {{hudson.plugins.sshslaves.SSHLauncher}} ), when I using script to check the {{credentialsId}} status, find out the {{jenkins.model.Jenkins.instance.nodes}} works as I saw in configure page, however, the {{jenkins.model.Jenkins.instance.computers}} still shows the legacy ( previous ) {{credentialsId}} .

           

          groovy script for list nodes credentials:
          {code:groovy}
          Jenkins.instance.computers.findAll { computer ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
            computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { computer ->
            println computer.node.launcher?.credentialsId?.toString() // shows updated, same with configuration page
            println computer.launcher?.credentialsId?.toString() // issue: shows the legacy credentialsId
          }

          "DONE"
          {code}
           

          screenshot:

          !image-2024-02-14-22-14-26-887.png|height=444!

          BTW, here is the groovy script to update nodes credential:
          {code:groovy}
          import jenkins.model.Jenkins
          import hudson.plugins.sshslaves.SSHLauncher
          import hudson.slaves.ComputerLauncher

          String newCredId = 'GIT_SSH_CREDENTIAL'

          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            ComputerLauncher launcher = node.launcher
            SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
            node.setLauncher( newLauncher )
            node.save()
            println ">> ${node.name} DONE <<"
          }
          {code}
          New: I've been updated credential ID in the SSH Agent ( {{hudson.plugins.sshslaves.SSHLauncher}} ), when I using script to check the {{credentialsId}} status, find out the {{jenkins.model.Jenkins.instance.nodes}} works as I saw in configure page, however, the {{jenkins.model.Jenkins.instance.computers}} still shows the legacy ( previous ) {{credentialsId}} .

           

          groovy script for list nodes credentials:
          {code:groovy}
          Jenkins.instance.computers.findAll { computer ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
            computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { computer ->
            println computer.node.launcher?.credentialsId?.toString()     // shows updated, same with configuration page
            println computer.launcher?.credentialsId?.toString()          // issue: shows the legacy credentialsId
          }

          "DONE"
          {code}
           

          screenshot:

          !image-2024-02-14-22-14-26-887.png|height=444!

          BTW, here is the groovy script to update nodes credential:
          {code:groovy}
          import jenkins.model.Jenkins
          import hudson.plugins.sshslaves.SSHLauncher
          import hudson.slaves.ComputerLauncher

          String newCredId = 'GIT_SSH_CREDENTIAL'

          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            ComputerLauncher launcher = node.launcher
            SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
            node.setLauncher( newLauncher )
            node.save()
            println ">> ${node.name} DONE <<"
          }
          {code}
          Marslo Jiao made changes -
          Labels New: Node SlaveComputer
          Marslo Jiao made changes -
          Labels Original: Node SlaveComputer New: DumbSlave Node SlaveComputer
          Marslo Jiao made changes -
          Attachment New: image-2024-02-14-22-33-44-839.png [ 62101 ]
          Description Original: I've been updated credential ID in the SSH Agent ( {{hudson.plugins.sshslaves.SSHLauncher}} ), when I using script to check the {{credentialsId}} status, find out the {{jenkins.model.Jenkins.instance.nodes}} works as I saw in configure page, however, the {{jenkins.model.Jenkins.instance.computers}} still shows the legacy ( previous ) {{credentialsId}} .

           

          groovy script for list nodes credentials:
          {code:groovy}
          Jenkins.instance.computers.findAll { computer ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
            computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { computer ->
            println computer.node.launcher?.credentialsId?.toString()     // shows updated, same with configuration page
            println computer.launcher?.credentialsId?.toString()          // issue: shows the legacy credentialsId
          }

          "DONE"
          {code}
           

          screenshot:

          !image-2024-02-14-22-14-26-887.png|height=444!

          BTW, here is the groovy script to update nodes credential:
          {code:groovy}
          import jenkins.model.Jenkins
          import hudson.plugins.sshslaves.SSHLauncher
          import hudson.slaves.ComputerLauncher

          String newCredId = 'GIT_SSH_CREDENTIAL'

          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            ComputerLauncher launcher = node.launcher
            SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
            node.setLauncher( newLauncher )
            node.save()
            println ">> ${node.name} DONE <<"
          }
          {code}
          New: I've been updated credential ID in the SSH Agent ( {{hudson.plugins.sshslaves.SSHLauncher}} ), when I using script to check the {{credentialsId}} status, find out the {{jenkins.model.Jenkins.instance.nodes}} works as I saw in configure page, however, the {{jenkins.model.Jenkins.instance.computers}} still shows the legacy ( previous ) {{credentialsId}} .

           

          groovy script for list nodes credentials:
          {code:groovy}
          Jenkins.instance.computers.findAll { computer ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
            computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { computer ->
            println computer.node.launcher?.credentialsId?.toString()     // shows updated, same with configuration page
            println computer.launcher?.credentialsId?.toString()          // issue: shows the legacy credentialsId
          }

          "DONE"
          {code}
           

          screenshot:

          !image-2024-02-14-22-33-44-839.png|height=400px!

          BTW, here is the groovy script to update nodes credential:
          {code:groovy}
          import jenkins.model.Jenkins
          import hudson.plugins.sshslaves.SSHLauncher
          import hudson.slaves.ComputerLauncher

          String newCredId = 'GIT_SSH_CREDENTIAL'

          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            ComputerLauncher launcher = node.launcher
            SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
            node.setLauncher( newLauncher )
            node.save()
            println ">> ${node.name} DONE <<"
          }
          {code}
          Marslo Jiao made changes -
          Attachment Original: image-2024-02-14-22-14-26-887.png [ 62100 ]
          Marslo Jiao made changes -
          Description Original: I've been updated credential ID in the SSH Agent ( {{hudson.plugins.sshslaves.SSHLauncher}} ), when I using script to check the {{credentialsId}} status, find out the {{jenkins.model.Jenkins.instance.nodes}} works as I saw in configure page, however, the {{jenkins.model.Jenkins.instance.computers}} still shows the legacy ( previous ) {{credentialsId}} .

           

          groovy script for list nodes credentials:
          {code:groovy}
          Jenkins.instance.computers.findAll { computer ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
            computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { computer ->
            println computer.node.launcher?.credentialsId?.toString()     // shows updated, same with configuration page
            println computer.launcher?.credentialsId?.toString()          // issue: shows the legacy credentialsId
          }

          "DONE"
          {code}
           

          screenshot:

          !image-2024-02-14-22-33-44-839.png|height=400px!

          BTW, here is the groovy script to update nodes credential:
          {code:groovy}
          import jenkins.model.Jenkins
          import hudson.plugins.sshslaves.SSHLauncher
          import hudson.slaves.ComputerLauncher

          String newCredId = 'GIT_SSH_CREDENTIAL'

          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            ComputerLauncher launcher = node.launcher
            SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
            node.setLauncher( newLauncher )
            node.save()
            println ">> ${node.name} DONE <<"
          }
          {code}
          New: I've been updated credential ID in the SSH Agent ( {{hudson.plugins.sshslaves.SSHLauncher}} ), when I using script to check the {{credentialsId}} status, find out the {{jenkins.model.Jenkins.instance.nodes}} works as I saw in configure page, however, the {{jenkins.model.Jenkins.instance.computers}} still shows the legacy ( previous ) {{credentialsId}} .

           

          groovy script for list nodes credentials:

          {{computer.getNode()}}:
          {code:groovy}
          Jenkins.instance.computers.findAll { computer ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(computer) &&
            computer?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { computer ->
            println computer.node.launcher?.credentialsId?.toString()     // shows updated, same with configuration page
            println computer.launcher?.credentialsId?.toString()          // issue: shows the legacy credentialsId
          }
          {code}
           
          {{node.toComputer()}}:
          {code:groovy}
          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            println node.launcher?.credentialsId?.toString() + ' : ' + node.getClass()
            println node.toComputer().launcher?.credentialsId?.toString() + ' : ' + node.toComputer().getClass()
          }
          {code}

          screenshot:

          !image-2024-02-14-22-33-44-839.png|height=400!

          BTW, here is the groovy script to update nodes credential:
          {code:groovy}
          import jenkins.model.Jenkins
          import hudson.plugins.sshslaves.SSHLauncher
          import hudson.slaves.ComputerLauncher

          String newCredId = 'GIT_SSH_CREDENTIAL'

          Jenkins.instance.nodes.findAll { node ->
            ! jenkins.model.Jenkins.MasterComputer.isInstance(node) &&
            node?.launcher instanceof hudson.plugins.sshslaves.SSHLauncher
          }.each { node ->
            ComputerLauncher launcher = node.launcher
            SSHLauncher newLauncher = new SSHLauncher( launcher.host, launcher.port, newCredId )
            node.setLauncher( newLauncher )
            node.save()
            println ">> ${node.name} DONE <<"
          }
          {code}
          Markus Winter made changes -
          Component/s New: ssh-slaves-plugin [ 15578 ]
          Component/s Original: ssh-agent-plugin [ 17509 ]
          Markus Winter made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]

            Unassigned Unassigned
            marslo Marslo Jiao
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: