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

jenkins sshagent is not working with parallel staging.

    XMLWordPrintable

Details

    Description

      def hosts=[]
      def TARGETLEVEL="L2"
      def UC_CM_ID="CM"monospaced text

      script
      {
      START_SERVER_LIST2.each
      {
      CURRENT_END_HOST="${it}".trim()
      END_SHORT_HOST="${CURRENT_END_HOST}".substring(0,"${CURRENT_END_HOST}".indexOf("."))
      CREDENTIAL_ID="$TARGETLEVEL""""$UC_CM_ID""""${END_SHORT_HOST}"
      hosts.add("${CREDENTIAL_ID}")

      }
      def servers = START_SERVER_LIST2
      def projectsBuilds = [:]
      for (int j=0; j<=5;j++)
      {
      def currentServer = START_SERVER_LIST2.get(j)
      projectsBuilds[currentServer] = {

      stage(String.format('%s execution', 'Checkout on'+currentServer))
      {

      def TAGNAME="TEST"
      def SOURCE_BRANCH_NAME="main"
      def TARGET_BRANCH_NAME="main"
      def SAVE_FILE_PATH="/tmp"
      def UTILITY_SCRIPT_DIR="/tmp"
      def level_name="L2"
      def user_name="cm"

      CURRENT_END_SERVER="${currentServer}".trim()
      END_SHORT_HOSTNAME="${CURRENT_END_SERVER}".substring(0,"${CURRENT_END_SERVER}".indexOf("."))
      END_CM_USER_CREDENTIAL_ID="$TARGETLEVEL""""$UC_CM_ID""""${END_SHORT_HOSTNAME}"
      echo "END_CM_USER_CREDENTIAL_ID=$END_CM_USER_CREDENTIAL_ID"
      sshagent(credentials: ["${END_CM_USER_CREDENTIAL_ID}""])

      { echo "currentServer=$currentServer" echo "END_SHORT_HOSTNAME=$END_SHORT_HOSTNAME" sh """ echo "$user_name"; echo $full_host_name; #ssh -oStrictHostKeyChecking=no -oBatchMode=yes -oLogLevel=error -oUserKnownHostsFile=/dev/null $user_name@$full_host_name /bin/ksh <<EOF """ }

      }
      }

      }
      echo "Parallel builds"
      print(projectsBuilds)
      parallel projectsBuilds;
      }

      we are creating stages dynamically based on the START_SERVER_LIST2 parameter. Created stages running parallelly except sshagent block. When sshagent starts its execution parallely it runs for only last server of START_SERVER_LIST2 parameter.

      Is sshagent blocks paralllel mechanism?
      how to run sshagent parallely for different servers?
      how to pass different parameter values for sshagent block?

      Attachments

        Activity

          pravin_kaldoke Pravin created issue -
          pravin_kaldoke Pravin made changes -
          Field Original Value New Value
          Status To Do [ 10003 ] In Progress [ 3 ]
          pravin_kaldoke Pravin made changes -
          Description def hosts=[]
          def TARGETLEVEL="L2"
          def UC_CM_ID="CM"{{monospaced text}}

          script
          {
              START_SERVER_LIST2.each
              {
                   CURRENT_END_HOST="${it}".trim()
          END_SHORT_HOST="${CURRENT_END_HOST}".substring(0,"${CURRENT_END_HOST}".indexOf("."))
                          CREDENTIAL_ID="$TARGETLEVEL"+"_"+"$UC_CM_ID"+"_"+"${END_SHORT_HOST}"
          hosts.add("${CREDENTIAL_ID}")
                 
              }
          def servers = START_SERVER_LIST2
                  def projectsBuilds = [:]
          for (int j=0; j<=5;j++)
          {
             def currentServer = START_SERVER_LIST2.get(j)
          projectsBuilds[currentServer] = {
                                     
          stage(String.format('%s execution', 'Checkout on'+currentServer))
          {
                          
                   def TAGNAME="TEST"
          def SOURCE_BRANCH_NAME="main"
                   def TARGET_BRANCH_NAME="main"
          def SAVE_FILE_PATH="/tmp"
          def UTILITY_SCRIPT_DIR="/tmp"
                   def level_name="L2"
          def user_name="cm"
                                             
                  CURRENT_END_SERVER="${currentServer}".trim()
          END_SHORT_HOSTNAME="${CURRENT_END_SERVER}".substring(0,"${CURRENT_END_SERVER}".indexOf("."))
                                  END_CM_USER_CREDENTIAL_ID="$TARGETLEVEL"+"_"+"$UC_CM_ID"+"_"+"${END_SHORT_HOSTNAME}"
          echo "END_CM_USER_CREDENTIAL_ID=$END_CM_USER_CREDENTIAL_ID"
          sshagent(credentials: ["${END_CM_USER_CREDENTIAL_ID}""])
          {
          echo "currentServer=$currentServer"
          echo "END_SHORT_HOSTNAME=$END_SHORT_HOSTNAME"
          sh """
                   echo "$user_name";
                           echo $full_host_name;
                                   #ssh -oStrictHostKeyChecking=no -oBatchMode=yes -oLogLevel=error -oUserKnownHostsFile=/dev/null $user_name@$full_host_name /bin/ksh <<EOF
          """
          }
          }
          }
                  
            }
          echo "Parallel builds"
          print(projectsBuilds)
          parallel projectsBuilds;
           }

          we are creating stages dynamically based on the START_SERVER_LIST2 parameter. Created stages running parallelly except sshagent block. When sshagent starts its execution parallely it runs for only last server os START_SERVER_LIST2 parameter.

          Is sshagent blocks paralllel mechanism?
          how to run sshagent parallely for different servers?
          how to pass different parameter values for sshagent block?
          def hosts=[]
           def TARGETLEVEL="L2"
           def UC_CM_ID="CM"{{monospaced text}}

          script
           {
           START_SERVER_LIST2.each
           {
           CURRENT_END_HOST="${it}".trim()
           END_SHORT_HOST="${CURRENT_END_HOST}".substring(0,"${CURRENT_END_HOST}".indexOf("."))
           CREDENTIAL_ID="$TARGETLEVEL"+"_"_+_"$UC_CM_ID"+"+_""${END_SHORT_HOST}"
           hosts.add("${CREDENTIAL_ID}")

          }
           def servers = START_SERVER_LIST2
           def projectsBuilds = [:]
           for (int j=0; j<=5;j++)
           {
           def currentServer = START_SERVER_LIST2.get(j)
           projectsBuilds[currentServer] = {

          stage(String.format('%s execution', 'Checkout on'+currentServer))
           {

          def TAGNAME="TEST"
           def SOURCE_BRANCH_NAME="main"
           def TARGET_BRANCH_NAME="main"
           def SAVE_FILE_PATH="/tmp"
           def UTILITY_SCRIPT_DIR="/tmp"
           def level_name="L2"
           def user_name="cm"

          CURRENT_END_SERVER="${currentServer}".trim()
           END_SHORT_HOSTNAME="${CURRENT_END_SERVER}".substring(0,"${CURRENT_END_SERVER}".indexOf("."))
           END_CM_USER_CREDENTIAL_ID="$TARGETLEVEL"+"_"_+_"$UC_CM_ID"+"+_""${END_SHORT_HOSTNAME}"
           echo "END_CM_USER_CREDENTIAL_ID=$END_CM_USER_CREDENTIAL_ID"
           sshagent(credentials: ["${END_CM_USER_CREDENTIAL_ID}""])

          { echo "currentServer=$currentServer" echo "END_SHORT_HOSTNAME=$END_SHORT_HOSTNAME" sh """ echo "$user_name"; echo $full_host_name; #ssh -oStrictHostKeyChecking=no -oBatchMode=yes -oLogLevel=error -oUserKnownHostsFile=/dev/null $user_name@$full_host_name /bin/ksh <<EOF """ }

          }
           }

          }
           echo "Parallel builds"
           print(projectsBuilds)
           parallel projectsBuilds;
           }

          we are creating stages dynamically based on the START_SERVER_LIST2 parameter. Created stages running parallelly except sshagent block. When sshagent starts its execution parallely it runs for only last server of START_SERVER_LIST2 parameter.

          Is sshagent blocks paralllel mechanism?
           how to run sshagent parallely for different servers?
           how to pass different parameter values for sshagent block?
          pravin_kaldoke Pravin made changes -
          Summary sshagent is not working with parallel staging in jenkins jenkins sshagent is not working with parallel staging.
          pravin_kaldoke Pravin made changes -
          Component/s core [ 21434 ]
          Issue Type Task [ 3 ] Bug [ 1 ]
          pravin_kaldoke Pravin made changes -
          Status In Progress [ 3 ] To Do [ 10003 ]
          pravin_kaldoke Pravin made changes -
          Status To Do [ 10003 ] In Review [ 10005 ]
          zbynek Zbynek Konecny made changes -
          Component/s core [ 15593 ]
          Component/s ssh-agent-plugin [ 17509 ]
          Component/s administrative [ 20861 ]
          Component/s content [ 20860 ]
          Component/s core [ 21434 ]
          Key WEBSITE-774 JENKINS-67025
          Workflow WEBSITE: Software Development Workflow [ 249004 ] JNJira + In-Review [ 251082 ]
          Project Jenkins Website [ 10401 ] Jenkins [ 10172 ]

          People

            pravin_kaldoke Pravin
            pravin_kaldoke Pravin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: