哪种类型的管道适合我? - Amazon CodePipeline
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

哪种类型的管道适合我?

管道类型由每个管道版本支持的一组特点与特征决定。

下面是每种管道类型的使用案例和特征摘要。

V1 类型 V2 类型
特性
使用案例
  • 标准部署

  • 通过在运行时传递管道级变量进行配置的部署

  • 将管道配置为在 Git 标签上启动的部署

操作级变量 支持 支持
并行执行模式 不支持 支持
管道级变量 不支持 支持
排队执行模式 不支持 支持
流水线阶段的回滚 不支持 支持
源修订覆盖 不支持 支持
触发和筛选 Git 标签、拉取请求、分支或文件路径 不支持 支持

有关定价的信息 CodePipeline,请参阅定价

在 V1 类型管道上使用以下脚本来分析将管道移至 V2 类型管道的成本。

运行管道类型的成本分析(脚本)
  1. 打开终端窗口。运行以下命令创建一个名为 PipelineCostAnalyzer.py 的新 python 脚本。

    vi PipelineCostAnalyzer.py
  2. 将以下代码复制并粘贴到 PipelineCostAnalyzer.py 脚本中。

    import boto3 import sys import math from datetime import datetime, timedelta, timezone if len(sys.argv) < 3: raise Exception("Please provide region name and pipeline name as arguments. Example usage: python PipelineCostAnalyzer.py us-east-1 MyPipeline") session = boto3.Session(profile_name='default', region_name=sys.argv[1]) pipeline = sys.argv[2] codepipeline = session.client('codepipeline') def analyze_cost_in_v2(pipeline_name): if codepipeline.get_pipeline(name=pipeline)['pipeline']['pipelineType'] == 'V2': raise Exception("Provided pipeline is already of type V2.") total_action_executions = 0 total_blling_action_executions = 0 total_action_execution_minutes = 0 cost = 0.0 hasNextToken = True nextToken = "" while hasNextToken: if nextToken=="": response = codepipeline.list_action_executions(pipelineName=pipeline_name) else: response = codepipeline.list_action_executions(pipelineName=pipeline_name, nextToken=nextToken) if 'nextToken' in response: nextToken = response['nextToken'] else: hasNextToken= False for action_execution in response['actionExecutionDetails']: start_time = action_execution['startTime'] end_time = action_execution['lastUpdateTime'] if (start_time < (datetime.now(timezone.utc) - timedelta(days=30))): hasNextToken= False continue total_action_executions += 1 if (action_execution['status'] in ['Succeeded', 'Failed', 'Stopped']): action_owner = action_execution['input']['actionTypeId']['owner'] action_category = action_execution['input']['actionTypeId']['category'] if (action_owner == 'Custom' or (action_owner == 'AWS' and action_category == 'Approval')): continue total_blling_action_executions += 1 action_execution_minutes = (end_time - start_time).total_seconds()/60 action_execution_cost = math.ceil(action_execution_minutes) * 0.02 total_action_execution_minutes += action_execution_minutes cost = round(cost + action_execution_cost, 2) print ("{:<40}".format('Activity in last 30 days:')) print ("| {:<40} | {:<10}".format('___________________________________', '__________________')) print ("| {:<40} | {:<10}".format('Total action executions:', total_action_executions)) print ("| {:<40} | {:<10}".format('Total billing action executions:', total_blling_action_executions)) print ("| {:<40} | {:<10}".format('Total billing action execution minutes:', round(total_action_execution_minutes, 2))) print ("| {:<40} | {:<10}".format('Cost of moving to V2 in $:', cost - 1)) analyze_cost_in_v2(pipeline)
  3. 根据给定 Amazon Web Services 区域的 V1 管道运行脚本。

    运行以下命令运行名为 PipelineCostAnalyzer.py 的 python 脚本。在此示例中,区域为 us-west-2。

    python3 PipelineCostAnalyzer.py us-west-2
  4. 在脚本的以下示例输出中,我们可以看到操作执行列表、符合计费条件的操作执行列表、这些操作执行的总运行时间,最后是将管道更新为 V2 类型的费用。

    Activity in last 30 days: 
     | ___________________________________      | __________________
     | Total action executions:                 | 9         
     | Total billing action executions:         | 9         
     | Total billing action execution minutes:  | 5.59      
     | Cost of moving to V2 in $:               | -0.76 
    注意

    在此示例中,最后一行的负值表示移至 V2 类型的管道所要节省的金额。