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

          People

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

            Dates

              Created:
              Updated: