日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

如何獲取大禹流水線連接配置和創建定制大禹流水線

本文介紹如何獲取大禹流水線連接配置,以及如何創建基于代碼部署和鏡像部署的大禹流水線。

獲取大禹流水線連接配置

  1. 登錄大禹-GTS工作臺
  2. 交付項目列表頁面,單擊目標交付項目。1
  3. 獲取AccessKey IDAccessKey Secret。在目標交付項目的左側導航欄中,參考下圖操作。1
    1. 選擇管理 > 設置
    2. 項目配置頁面,單擊OpenAPI
    3. 單擊創建AccessKey,單擊復制,將AccessKey IDAccessKey Secret保存至本地。1
      說明 查看Secret對話框關閉后,您無法再次查詢Secret。如果您遺失該AccessKey,可以創建新的AccessKey替代。
  4. 獲取大禹項目ID大禹用戶ID1
    上圖中:
    • businessId對應大禹項目ID
    • 用戶ID對應大禹用戶ID
    當您在新建流水線連接時,關于大禹項目ID大禹用戶ID信息您可以通過該步驟獲取。而AccessKey IDAccessKey Secret信息您可以通過步驟3獲取。1

創建大禹流水線

  1. 在目標交付項目的左側導航欄中,選擇研運 > 應用1
  2. 單擊1圖標。
  3. 創建研發項目面板,填寫名稱標識描述(選填),完成后單擊確定1
  4. 在新建研發項目的基本信息頁簽,單擊新增應用1
  5. 完成新建應用的相關配置。1
    1. 選擇目標應用。
    2. 選擇目標應用類型。
    3. 設置目標應用詳細信息:名稱標識描述(選填)、倉庫,以及選擇應用是否為空應用
    4. 完成后單擊確定
  6. 新建定制流水線。
    1. 在目標應用的應用概覽頁簽,單擊定制流水線1
    2. 在目標應用的定制流水線頁簽,單擊新建定制流水線1
    3. 新建流水線對話框中,設置流水線名稱所屬研發項目流水線模板所屬應用分支模式分支觸發方式,完成后,單擊保存1
  7. 在目標流水線ID右側操作列下,選擇更多 > 編輯1
  8. 編輯流水線頁面,您可以參考以下步驟完成流水線編輯操作。1
    說明 代碼準備(代碼準備)節點不支持編輯,代碼克隆(準備階段)節點不支持編輯和刪除。
    • 新增自定義腳本節點。單擊1圖標,在選擇任務類型對話框中,單擊工具頁簽后,單擊自定義腳本1
      新建階段面板,完成階段名稱自定義腳本設置后,單擊確定1

      創建基于代碼部署的大禹流水線。

      1. 新增第一個自定義腳本節點:Java代碼克隆,具體腳本示例如下。
        echo "========================== ${STAGE_NAME} =========================="
        
        updateStatus(){
          pipelineId=$(echo ${JOB_NAME} | awk -F"-" '{print $(NF-1)}')
          rm -rf ${JOB_NAME}-${BuildId}
          result=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/updateDeploymentStatusWebhook?x-bw-us-auth-way=jwt&access_token=${BW_AUTH_TOKEN}" \
                        -H "Content-Type: application/json" \
                        -X POST -d "{\"task\": {\"pipelineId\": \"${pipelineId}\",\"buildNumber\": \"${BuildId}\",\"statusCode\": \"FAIL\"},
                        \"globalParams\": [{\"key\": \"BW_TENANT_ID\", \"value\": \"${BW_TENANT_ID}\"},{\"key\": \"BW_USER_ID\", \"value\": \"${BW_USER_ID}\"},
                        {\"key\": \"BW_DEPLOYMENT_CODE\", \"value\": \"${BW_DEPLOYMENT_CODE}\"}]}")
        
          if [ $(echo "${result}" | grep -c '"code":"OK"') = 0 ] ; then
            echo "更新流水線狀態 [  失敗  ] - $result"
            exit 1
          else
            echo "更新流水線狀態 [  成功  ]"
          fi
        }
        
        mkdir ${JOB_NAME}-${BuildId}
        cd ${JOB_NAME}-${BuildId}
        echo "代碼倉庫:${BW_GIT_REPO_HTTP_URL}"
        url=$(echo "${BW_GIT_REPO_HTTP_URL}" | awk -F '//' '{print $2}')
        git_url=$(echo http://${BW_GIT_REPO_USERNAME}:${BW_GIT_REPO_PASSWORD}@${url})
        
        if [ ! -z "${BW_GIT_REPO_TAG}" ]; then
          echo "構建Tag:${BW_GIT_REPO_TAG}"
          git clone -c advice.detachedHead=false --depth 1 --single-branch --branch ${BW_GIT_REPO_TAG} ${git_url} .
        elif [ ! -z "${BW_GIT_REPO_COMMIT_ID}" ]; then
          echo "構建commitId:${BW_GIT_REPO_COMMIT_ID}"
          git clone ${git_url} . && git reset --hard ${BW_GIT_REPO_COMMIT_ID}
        elif [ ! -z "${BW_GIT_REPO_BRANCH}" ]; then
          echo "構建分支:${BW_GIT_REPO_BRANCH}"
          git clone --depth 1 --single-branch --branch ${BW_GIT_REPO_BRANCH} ${git_url} .
        fi
        
        if [ "$?" != 0 ]; then
          echo "克隆代碼失敗,請檢查代碼倉庫地址、用戶名、密碼是否正確"
          updateStatus
          exit 1
        fi
      2. 新增一個自定義腳本節點:Java代碼構建,具體腳本示例如下。
        echo "========================== ${STAGE_NAME} =========================="
        
        updateStatus(){
          pipelineId=$(echo ${JOB_NAME} | awk -F"-" '{print $(NF-1)}')
          rm -rf ${JOB_NAME}-${BuildId}
          result=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/updateDeploymentStatusWebhook?x-bw-us-auth-way=jwt&access_token=${BW_AUTH_TOKEN}" \
                        -H "Content-Type: application/json" \
                        -X POST -d "{\"task\": {\"pipelineId\": \"${pipelineId}\",\"buildNumber\": \"${BuildId}\",\"statusCode\": \"FAIL\"},
                        \"globalParams\": [{\"key\": \"BW_TENANT_ID\", \"value\": \"${BW_TENANT_ID}\"},{\"key\": \"BW_USER_ID\", \"value\": \"${BW_USER_ID}\"},
                        {\"key\": \"BW_DEPLOYMENT_CODE\", \"value\": \"${BW_DEPLOYMENT_CODE}\"}]}")
        
          if [ $(echo "${result}" | grep -c '"code":"OK"') = 0 ] ; then
            echo "更新流水線狀態 [  失敗  ] - $result"
            exit 1
          else
            echo "更新流水線狀態 [  成功  ]"
          fi
        }
        
        cd ${JOB_NAME}-${BuildId}
        if [ -z "${BW_BUILD_MODULE_PATH}" ];then
          MODULE_DIR=$(ls | grep -e "-start")
        else
          MODULE_DIR=${BW_BUILD_MODULE_PATH}
        fi
        
        if [ ! -d "${MODULE_DIR}" ];then
          echo "---------------------------------------------------------------"
          echo " MODULE_PATH 不存在,請檢查Module名稱是否正確。"
          updateStatus
          exit 1
        fi
        
        if [ "${BW_APPLICATION_TYPE}" = "SourceCode" ]; then
          MVN_PLUGIN_PARAM="-DtenantId=${BW_TENANT_ID} -DprojectCode=${BW_PROJECT_CODE} -DapplicationCode=${BW_APPLICATION_CODE} -DlogicFlowServer=${BW_LOGIC_FLOW_SERVER}"
        fi
        
        if [ ! -f "${BW_BUILD_SETTINGS_PATH}" ]; then
          echo "構建命令:mvn ${MVN_PLUGIN_PARAM} -Duser.timezone=GMT+08 -f pom.xml -U clean package -Dmaven.test.skip=true"
          mvn ${MVN_PLUGIN_PARAM} -Duser.timezone=GMT+08 -f pom.xml -U clean package -Dmaven.test.skip=true
        else
          echo "構建命令:mvn ${MVN_PLUGIN_PARAM} -Duser.timezone=GMT+08 -f pom.xml -s ${BW_BUILD_SETTINGS_PATH} -U clean package -Dmaven.test.skip=true"
          mvn ${MVN_PLUGIN_PARAM} -Duser.timezone=GMT+08 -f pom.xml -s ${BW_BUILD_SETTINGS_PATH} -U clean package -Dmaven.test.skip=true
        fi
        
        if [ $(ls -l ${MODULE_DIR}/target/*.jar | wc -l) -eq 1 ];then
          JAR_PACKAGE=$(ls ${MODULE_DIR}/target/*.jar | awk -F '/' '{print $NF}')
          cp ${MODULE_DIR}/target/${JAR_PACKAGE} ${BW_BUILD_DOCKERFILE_PATH}/${JAR_PACKAGE}
        else
          echo "---------------------------------------------------------------"
          echo "代碼編譯失敗,請檢查錯誤日志,可能的原因:"
          echo "1. 工程根目錄下沒有settings.xml文件,編譯過程中拉取依賴的jar包失敗。"
          echo "2. ${MODULE_DIR}/target目錄下沒有編譯后的jar包。"
          updateStatus
          exit 1
        fi
      3. 新增一個自定義腳本節點:鏡像構建,具體腳本示例如下。
        echo "========================== ${STAGE_NAME} =========================="
        
        updateStatus(){
          pipelineId=$(echo ${JOB_NAME} | awk -F"-" '{print $(NF-1)}')
          rm -rf ${JOB_NAME}-${BuildId}
          result=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/updateDeploymentStatusWebhook?x-bw-us-auth-way=jwt&access_token=${BW_AUTH_TOKEN}" \
                        -H "Content-Type: application/json" \
                        -X POST -d "{\"task\": {\"pipelineId\": \"${pipelineId}\",\"buildNumber\": \"${BuildId}\",\"statusCode\": \"FAIL\"},
                        \"globalParams\": [{\"key\": \"BW_TENANT_ID\", \"value\": \"${BW_TENANT_ID}\"},{\"key\": \"BW_USER_ID\", \"value\": \"${BW_USER_ID}\"},
                        {\"key\": \"BW_DEPLOYMENT_CODE\", \"value\": \"${BW_DEPLOYMENT_CODE}\"}]}")
        
          if [ $(echo "${result}" | grep -c '"code":"OK"') = 0 ] ; then
            echo "更新流水線狀態 [  失敗  ] - $result"
            exit 1
          else
            echo "更新流水線狀態 [  成功  ]"
          fi
        }
        
        cd ${JOB_NAME}-${BuildId}
        JAR_PACKAGE=$(ls ${BW_BUILD_DOCKERFILE_PATH}/*.jar | awk -F '/' '{print $NF}')
        chmod a+r ${BW_BUILD_DOCKERFILE_PATH}/*.jar
        BW_TARGET_REGISTRY_URL=$(echo ${BW_TARGET_IMAGE_URL} | awk -F '/' '{print $1}')
        
        docker login --username=${BW_TARGET_REGISTRY_USERNAME} --password=${BW_TARGET_REGISTRY_PASSWORD} ${BW_TARGET_REGISTRY_URL}
        if [ "$?" != 0 ]; then
          echo "${BW_TARGET_REGISTRY_URL} 登錄失敗,請檢查鏡像倉庫地址、用戶名、密碼是否正確。"
          updateStatus
          exit 1
        fi
        
        docker build --pull --build-arg JAR_PACKAGE=${JAR_PACKAGE} -t ${BW_TARGET_IMAGE_URL} ${BW_BUILD_DOCKERFILE_PATH}/
        
        docker push ${BW_TARGET_IMAGE_URL}
        if [ "$?" != 0 ]; then
          echo "推送鏡像失敗,請檢查鏡像倉庫地址、用戶名、密碼是否正確。"
          updateStatus
          exit 1
        fi
        
        docker rmi ${BW_TARGET_IMAGE_URL}
      4. 新增一個自定義腳本節點:應用部署,具體腳本示例如下。
        echo "========================== ${STAGE_NAME} =========================="
        
        updateStatus(){
          pipelineId=$(echo ${JOB_NAME} | awk -F"-" '{print $(NF-1)}')
          rm -rf ${JOB_NAME}-${BuildId}
          result=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/updateDeploymentStatusWebhook?x-bw-us-auth-way=jwt&access_token=${BW_AUTH_TOKEN}" \
                        -H "Content-Type: application/json" \
                        -X POST -d "{\"task\": {\"pipelineId\": \"${pipelineId}\",\"buildNumber\": \"${BuildId}\",\"statusCode\": \"FAIL\"},
                        \"globalParams\": [{\"key\": \"BW_TENANT_ID\", \"value\": \"${BW_TENANT_ID}\"},{\"key\": \"BW_USER_ID\", \"value\": \"${BW_USER_ID}\"},
                        {\"key\": \"BW_DEPLOYMENT_CODE\", \"value\": \"${BW_DEPLOYMENT_CODE}\"}]}")
        
          if [ $(echo "${result}" | grep -c '"code":"OK"') = 0 ] ; then
            echo "更新流水線狀態 [  失敗  ] - $result"
            exit 1
          else
            echo "更新流水線狀態 [  成功  ]"
          fi
        }
        
        code=$(curl -I -m 10 -o /dev/null -s -w %{http_code} ${BW_DOMAIN_NAME})
        echo ${code}
        if [ "${code}" != 200 ];then
          echo "訪問 ${BW_DOMAIN_NAME} 地址異常"
          updateStatus
          exit 1
        fi
        
        result=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/deployInstance" \
                      -H "Content-Type: application/json" \
                      -H "x-bw-us-auth-way: jwt" \
                      -H "Authorization: Bearer ${BW_AUTH_TOKEN}" \
                      -H "x-bw-tenant-id: ${BW_TENANT_ID}" \
                      -H "x-bw-user-id: ${BW_USER_ID}" \
                      -H "x-bw-user-name: ${BW_USER_NAME}" \
                      -X POST -d "{\"deploymentCode\": \"${BW_DEPLOYMENT_CODE}\"}")
        if [ $(echo "${result}" | grep -c '"code":"OK"') = 0 ] ; then
          echo "觸發應用部署 [  失敗  ] - ${result}"
          updateStatus
          exit 1
        else
          echo "觸發應用部署 [  成功  ]"
        fi
        
        # 檢查實例狀態
        while :; do
          sleep 5
          status=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/getInstanceDeployStatusFromPipeline" \
                        -H "Content-Type: application/json" \
                        -H "x-bw-us-auth-way: jwt" \
                        -H "Authorization: Bearer ${BW_AUTH_TOKEN}" \
                        -H "x-bw-tenant-id: ${BW_TENANT_ID}" \
                        -H "x-bw-user-id: ${BW_USER_ID}" \
                        -H "x-bw-user-name: ${BW_USER_NAME}" \
                        -X POST -d "{\"deploymentCode\": \"${BW_DEPLOYMENT_CODE}\"}")
          # echo $result
          if [ $(echo ${status} | grep '"code":"OK"' | grep 'Running' | wc -l) = 1 ] ; then
            echo "檢查部署狀態 [ 部署中 ]"
          elif [ $(echo ${status} | grep '"code":"OK"' | grep 'Cancelled' | wc -l) = 1 ] ; then
            echo "檢查部署狀態 [  取消  ]"
            updateStatus
            exit 1
          elif [ $(echo ${status} | grep '"code":"OK"' | grep 'Failed' | wc -l) = 1 ] ; then
            echo "檢查部署狀態 [  失敗  ]"
            updateStatus
            exit 1
          elif [ $(echo ${status} | grep '"code":"OK"' | grep 'Succeeded' | wc -l) = 1 ] ; then
            echo "檢查部署狀態 [  成功  ]"
            rm -rf ${JOB_NAME}-${BuildId}
            exit 0
          elif [ $(echo ${status} | grep '"code":"OK"' | grep 'Abnormal' | wc -l) = 1 ] ; then
            echo "檢查部署狀態 [  異常  ]"
            rm -rf ${JOB_NAME}-${BuildId}
            exit 1
          else
            echo "檢查部署狀態 [  失敗  ]"
            updateStatus
            exit 1
          fi
        done
      編輯流水線頁面,您可以查看到新建的節點。1

      創建基于鏡像部署的大禹流水線

      新增一個自定義腳本節點:應用部署,具體腳本示例如下。
      echo "========================== ${STAGE_NAME} =========================="
      
      updateStatus(){
        pipelineId=$(echo ${JOB_NAME} | awk -F"-" '{print $(NF-1)}')
        result=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/updateDeploymentStatusWebhook?x-bw-us-auth-way=jwt&access_token=${BW_AUTH_TOKEN}" \
                      -H "Content-Type: application/json" \
                      -X POST -d "{\"task\": {\"pipelineId\": \"${pipelineId}\",\"buildNumber\": \"${BuildId}\",\"statusCode\": \"FAIL\"},
                      \"globalParams\": [{\"key\": \"BW_TENANT_ID\", \"value\": \"${BW_TENANT_ID}\"},{\"key\": \"BW_USER_ID\", \"value\": \"${BW_USER_ID}\"},
                      {\"key\": \"BW_DEPLOYMENT_CODE\", \"value\": \"${BW_DEPLOYMENT_CODE}\"}]}")
      
        if [ $(echo "${result}" | grep -c '"code":"OK"') = 0 ] ; then
          echo "更新流水線狀態 [  失敗  ] - $result"
          exit 1
        else
          echo "更新流水線狀態 [  成功  ]"
        fi
      }
      
      code=$(curl -I -m 10 -o /dev/null -s -w %{http_code} ${BW_DOMAIN_NAME})
      echo ${code}
      if [ "${code}" != 200 ];then
        echo "訪問 ${BW_DOMAIN_NAME} 地址異常"
        updateStatus
        exit 1
      fi
      
      result=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/deployInstance" \
                    -H "Content-Type: application/json" \
                    -H "x-bw-us-auth-way: jwt" \
                    -H "Authorization: Bearer ${BW_AUTH_TOKEN}" \
                    -H "x-bw-tenant-id: ${BW_TENANT_ID}" \
                    -H "x-bw-user-id: ${BW_USER_ID}" \
                    -H "x-bw-user-name: ${BW_USER_NAME}" \
                    -X POST -d "{\"deploymentCode\": \"${BW_DEPLOYMENT_CODE}\"}")
      if [ $(echo "${result}" | grep -c '"code":"OK"') = 0 ] ; then
        echo "觸發應用部署 [  失敗  ] - ${result}"
        updateStatus
        exit 1
      else
        echo "觸發應用部署 [  成功  ]"
      fi
      
      # 檢查實例狀態
      while :; do
        sleep 5
        status=$(curl -s "${BW_DOMAIN_NAME}/devBackend/v2/deployment/getInstanceDeployStatusFromPipeline" \
                      -H "Content-Type: application/json" \
                      -H "x-bw-us-auth-way: jwt" \
                      -H "Authorization: Bearer ${BW_AUTH_TOKEN}" \
                      -H "x-bw-tenant-id: ${BW_TENANT_ID}" \
                      -H "x-bw-user-id: ${BW_USER_ID}" \
                      -H "x-bw-user-name: ${BW_USER_NAME}" \
                      -X POST -d "{\"deploymentCode\": \"${BW_DEPLOYMENT_CODE}\"}")
        # echo $result
        if [ $(echo ${status} | grep '"code":"OK"' | grep 'Running' | wc -l) = 1 ] ; then
          echo "檢查部署狀態 [ 部署中 ]"
        elif [ $(echo ${status} | grep '"code":"OK"' | grep 'Cancelled' | wc -l) = 1 ] ; then
          echo "檢查部署狀態 [  取消  ]"
          updateStatus
          exit 1
        elif [ $(echo ${status} | grep '"code":"OK"' | grep 'Failed' | wc -l) = 1 ] ; then
          echo "檢查部署狀態 [  失敗  ]"
          updateStatus
          exit 1
        elif [ $(echo ${status} | grep '"code":"OK"' | grep 'Succeeded' | wc -l) = 1 ] ; then
          echo "檢查部署狀態 [  成功  ]"
          exit 0
        elif [ $(echo ${status} | grep '"code":"OK"' | grep 'Abnormal' | wc -l) = 1 ] ; then
          echo "檢查部署狀態 [  異常  ]"
          exit 1
        else
          echo "檢查部署狀態 [  失敗  ]"
          updateStatus
          exit 1
        fi
      done
      編輯流水線頁面,您可以查看到新建的節點。1
    • 刪除節點。單擊1圖標。