CI/CD——持续集成与交付

最近更新时间:2025-12-12 11:03:02

我的收藏

使用场景

持续集成和持续交付 (Continuous integration and continuous delivery,CI/CD) 是指通过使用自动化流水线,以短周期、高频率的方式开发和交付软件的过程。CI/CD 在软件开发中很常见,并且对数据工程和数据科学也越来越重要。相比手动流程,通过自动化代码的构建、测试和部署,开发团队能够更可靠地交付版本。
WeData 使用 WeData bundle 功能实现 CI/CD 能力。使用 bundle 将 WeData 上的资源(工作流、任务、资源文件、项目参数、告警规则、事件)描述为源文件,这些文件包可以进行源代码控制,并且您可以使用外部 CI/CD 自动化(例如 GitHub Actions)来触发运行、测试和部署。
功能简介:
将项目内资源配置信息定义为 yml 文件,可通过修改 yml 文件修改资源配置信息。
提供 bundle 相关命令,可实现资源运行、测试、部署等能力。
支持在 bundle 中配置开发和生产项目信息,从而实现开发生产隔离。
可结合外部版本管控系统(如 GitHub、GitLab)实现自动化触发运行、测试、部署的能力。

功能架构



使用 bundle 开发

1. 第一步:安装并登录

1. 安装客户端。
命令行中执行安装命令:
#Install the WeData client (no installation package required, simply run the program).
#macOS system installation
curl https://wedata-agent-gz-1257305158.cos.ap-guangzhou.myqcloud.com/bundle/install-script/linux/install.sh |sudo sh -s -- --region 'https://ap-guangzhou.wedata.cloud.tencent.com'
#windows system installation
curl.exe -fsSL https://wedata-agent-gz-1257305158.cos.ap-guangzhou.myqcloud.com/bundle/install-script/windows/install.bat -o install.bat && install.bat --region "https://ap-guangzhou.wedata.cloud.tencent.com"
返回 Installation successful 即表示安装成功。

2. 登录客户端。
执行登录命令后将跳转到产品登录界面,完成登录后即可自动完成客户端登录。
wedata auth login
页面出现验证成功即表示客户端登录成功。


2. 第二步:初始化 bundle 包

1. 初始化并配置 bundle 包。
执行初始化 bundle 命令。
wedata bundle init
2. 配置 wedata.yml 文件。
在 wedata.yml 文件的 targets 中,修改开发环境和生产环境对应的项目 url。
mode:development表示开发环境、production表示生产环境。
host:表示某环境对应的项目 url,选择任意带地域信息和项目 ID 信息的 url 即可。
root_path:production 项目可以指定 bundle 包在 WeData Studio 存储的位置。
targets:
dev:
mode: development
workspace:
host: https://wedata-studio-fusion.cloud.tencent.com/studio/clone/packages/edit/11336a82-dd7c-4ba6-b3a6-74bda71cc237?ProjectId=2998786495253803008
default: true
prod:
mode: production
workspace:
host: https://wedata-studio-fusion.cloud.tencent.com/studio/datadev/workflow?ProjectId=2995753587734867968
root_path: /Workspace/Users/test5-auto-test1/.bundle/${bundle.name}/${bundle.target}
3. 拉取资源并绑定。
从产品中拉取需要的资源进行绑定,绑定后按需要进行本地开发(修改本地资源yml文件)。
拉取资源:拉取工作流后,会将工作流下的任务也一并拉取到本地 bundle 包中。
wedata bundle generate workflow --existing-workflow-id ${workflow_id} -t dev -p profile_name
绑定资源:
执行下面的命令绑定工作流和任务。
${resource key}:当前资源实体在本地 bundle 包中的唯一 key,在资源对应 yaml 文件下图位置。

wedata bundle deployment bind task ${resource key} ${task_id} -t dev -p profile_name
wedata bundle deployment bind workflow ${resource key} ${workflow_id} -t dev -p profile_name

3. 第三步:验证、运行并部署

执行验证命令,部署前验证 bundle 包是否存在异常问题。
执行运行命令,运行任务进行验证。
执行部署命令,完成部署。
wedata bundle validate -t dev
wedata bundle run task ${resource key} -t dev -p profile_name
wedata bundle deploy -t dev

实践教程(与 GitLab 联动实现自动触发流水线部署)

1. 第一步:安装并登录

1. 安装客户端。
命令行中执行安装命令。
#Install the WeData client (no installation package required, simply run the program).
#macOS system installation
curl https://wedata-agent-gz-1257305158.cos.ap-guangzhou.myqcloud.com/bundle/install-script/linux/install.sh |sudo sh -s -- --region 'https://ap-guangzhou.wedata.cloud.tencent.com'
#windows system installation
curl.exe -fsSL https://wedata-agent-gz-1257305158.cos.ap-guangzhou.myqcloud.com/bundle/install-script/windows/install.bat -o install.bat && install.bat --region "https://ap-guangzhou.wedata.cloud.tencent.com"
返回 Installation successful 即表示安装成功。

2. 登录客户端。
执行登录命令后将跳转到产品登录界面,完成登录后即可自动完成客户端登录。
wedata auth login
页面出现验证成功即表示客户端登录成功。


2. 第二步:初始化 bundle 包

1. 初始化并配置 bundle 包。
执行初始化 bundle 命令
wedata bundle init
2. 配置 wedata.yml 文件。
在 wedata.yml 文件的 targets 中,修改开发环境和生产环境对应的项目 url。
mode:development 表示开发环境、production 表示生产环境。
host:表示某环境对应的项目 url,选择任意带地域信息和项目 ID 信息的 url 即可。
root_path:production 项目可以指定 bundle 包在 WeData Studio 存储的位置。
targets:
dev:
mode: development
workspace:
host: https://wedata-studio-fusion.cloud.tencent.com/studio/clone/packages/edit/11336a82-dd7c-4ba6-b3a6-74bda71cc237?ProjectId=2998786495253803008
default: true
prod:
mode: production
workspace:
host: https://wedata-studio-fusion.cloud.tencent.com/studio/datadev/workflow?ProjectId=2995753587734867968
root_path: /Workspace/Users/test5-auto-test1/.bundle/${bundle.name}/${bundle.target}

3. 第三步:绑定 git 仓库,构建流水线

1. 构建 git 仓库,使用 git 仓库工具,将本地仓库与远端 git 仓库进行绑定。
构建远端 git 仓库,仓库包含两个分支,一个是 dev 分支,一个是 prod 分支。
这里使用的是 ugit 工具,客户也可以使用其他工具进行本地和远端仓库的绑定。

2. 配置流水线文件,并放在 git 仓库中。
编写流水线触发文件,逻辑为若向 dev 分支 push 则执行验证和部署到 dev 环境的 bundle 命令,若向 prod 分支合并则执行验证和部署到 prod 环境的 bundle 命令。
注意:
这里为系统推荐触发逻辑,您也可以按需定义所需环境及触发流水线逻辑。
对应命令如下:
dev 环境对应命令:
wedata bundle validate -t dev
wedata bundle deploy -t dev
prod 环境对应命令:
wedata bundle validate -t prod
wedata bundle deploy -t prod
git 流水线触发文件:将当前文件放在 git 仓库的第一层目录下。
注意:
该内容需按照注释进行修改,且不同的 GitLab 版本可能存在差异,需按情况进行修改和调整才能使用。
stages:
- build

# The build logic of the dev branch
build_dev:
stage: build
tags:
- docker #CICD machine label, modify as needed
script:
- |
set -ex
apk add --no-cache curl sudo
curl https://wedata-agent-sg-1257305158.cos.ap-singapore.myqcloud.com/bundle/install-script/linux/install.sh |sudo sh -s -- --region 'https://api-ap-singapore.wedata.tencentcloud.com'
#Download the client script; it needs to be modified to suit different environments.
# Create configuration file
config_file="$HOME/.wedatacfg"
if [ ! -f "$config_file" ]; then
echo "The configuration file does not exist; create a new configuration file..."
echo "host =https://ap-singapore.wedata.cloud.tencent.com/studio/datadev/workflow?ProjectId=2430455587205529600" > "$config_file"
#It needs to be modified to any wedata URL in the current environment.
echo "secret_id =******" >> "$config_file"
#current user's secret_id
echo "secret_key =******" >> "$config_file"
#current user's secret_key
echo "region =ap-singapore" >> "$config_file"
#Modify to the corresponding area
echo "is_intl =false" >> "$config_file"
echo "The content is as follows:"
cat "$config_file"
else
echo "Current configuration details:"
cat "$config_file"
fi
cd wedata-cicd-test/cicd_bjjr/v_vyuyudu_bjjr/
# Path to the corresponding bundle

echo "This is the build logic for the dev branch."
wedata bundle validate -t dev
echo "Start pushing to the dev environment:"
wedata bundle deploy -t dev
only:
- dev #Change to the git branch name

# The construction logic of the prod branch
build_prod:
stage: build
tags:
- docker
script:
- |
set -ex

apk add --no-cache curl sudo
curl https://wedata-agent-sg-1257305158.cos.ap-singapore.myqcloud.com/bundle/install-script/linux/install.sh |sudo sh -s -- --region 'https://api-ap-singapore.wedata.tencentcloud.com'
#Download the client script; you'll need to modify it to suit different environments.
# Create configuration file
config_file="$HOME/.wedatacfg"
if [ ! -f "$config_file" ]; then
echo "The configuration file does not exist; create a new configuration file..."
echo "host =https://ap-singapore.wedata.cloud.tencent.com/studio/datadev/workflow?ProjectId=2430455587205529600" > "$config_file"
#It needs to be modified to any wedata URL in the current environment.
echo "secret_id =******" >> "$config_file"
echo "secret_key =******" >> "$config_file"
echo "region =ap-singapore" >> "$config_file"
echo "is_intl =false" >> "$config_file"
echo "The content is as follows:"
cat "$config_file"
else
echo "Current configuration details:"
cat "$config_file"
fi
cd wedata-cicd-test/cicd_bjjr/v_vyuyudu_bjjr/

echo "This is the build logic for the prod branch."
wedata bundle validate -t prod
echo "Start pushing to the prod environment:"
wedata bundle deploy -t prod
only:
- merge_requests # Triggered for merge scenarios
- prod # Triggered on the prod branch

4. 第四步:dev 环境开发并提交

本地编辑器上修改 bundle 包内容来进行开发,开发完后使用 ugit 提交到 dev 分支。
提交后将自动触发流水线并将修改内容部署到 dev 环境对应的项目中。


5. 第五步:合并到 prod 分支

将 dev 分支的变动合并到 prod 分支,并自动触发流水线将修改内容部署到 prod 环境对应的项目中。




bundle 包定义

1. wedata.yml

用于定义 bundle 基础信息和 target 信息,包含内容为:
bundle 基础信息:名称、uuid、客户端版本。
include:包含文件路径,及bundle包含的资源范围,resources/*/*.yml表示 resource 下所有 yaml 文件,客户可自行定义 bundle 包的资源范围。
target:用于定义目标项目,可按需定义不同环境对应的项目。
mode:development 表示开发环境、production 表示生产环境。
host:表示某环境对应的项目 url,选择任意带地域信息和项目 ID 信息的 url 即可。
root_path:production 项目可以指定 bundle 包在 WeData Studio 存储的位置。
variables:定义在 bundle 中需要使用的参数,常用场景是不同环境对应的配置信息不同,可通过在不同环境定义不同的参数值来解决这个问题。
# This is a Wedata asset bundle definition
bundle:
name: wedataBundleDemo
uuid: e1e95042-9e18-4806-a2e6-8de5e535881c
wedata_cli_version: '0.18.*'
# allow any Wedata CLI version between 0.218.0 and 1.0.0, inclusive
# wedata_cli_version: '>= 0.218.0, <= 1.0.0'

# Paths to match based on root directory
include:
- resources/*/*.yml

# Deploy synchronizes default+include folders that are not filtered by exclude rules, using Glob pattern
sync:
include:
- "resources/**"
- "src/**"
- "tests/**"
exclude:
- "tests/README.md"

targets:
dev:
# The default target uses 'mode: development' to create a development copy.
# - Deployed resources get prefixed with '[dev my_user_name]'
# - Any job schedules and triggers are paused by default.
mode: development
# Specify the environment configuration for the current bundle
default: true
variables: #You can define different environment variables here
test_worker_group_id: "20241120210318772642"
cluster_id: "123"
workspace:
# projectAddr
host: https://ap-beijing.wedata.cloud.tencent.com/studio/datadev/workflow?ProjectId=1460726726769418240
# root_path: ~/.bundle/${bundle.name}/${bundle.target}
# ~/ also represents the user's personal path, equivalent to root_path: /Workspace/Users/${workspace.current_user.userName}/.bundle/${bundle.name}/${bundle.target}
# Note: root_path must start with '~/' or contain the current username to ensure uniqueness when using 'mode: development'
prod:
mode: production
variables: #You can define different environment variables here
test_worker_group_id: "2024112021031872222"
cluster_id: "111"
workspace:
# projectAddr
host: https://ap-beijing.wedata.cloud.tencent.com/studio/datadev/workflow?ProjectId=1460726726769418240
# We explicitly deploy to /Workspace/Users/asherxu@tencent.com to make sure we only have a single copy.
root_path: /Workspace/Users/demo@tencent.com/.bundle/${bundle.name}/${bundle.target}

# Global custom variables, usage definition: ${var.<variable_name>}
variables:
test_worker_group_id:
description: defaultGroupID
default: "20241120210318772644"
type: string
cluster_id:
description: defaultClusterID
default: "234"
type: string

2. 资源实体

bundle 包中可包含的资源类型有:工作流、任务、资源文件、项目参数、告警规则、事件,下面将介绍不同资源在 bundle 中如何配置。
大部分配置与创建实体对应的 OpenAPI 中定义的入参名称完全相同,可参考 OpenAPI 中的定义。

2.1 工作流

resources:
workflows:
workflowResourceKey:
name: workflowName
# Wedata remote directory
remoteDirPath: /默认文件夹/temp/
# Task owner
ownerName: ownername
# Workflow description
workflowDesc: workflowDesc
# Workflow type, cycle: cycle manual: manual
workflowType: cycle
# Workflow parameters
workflowParams:
paramDs: []
# Scheduling cycle
workflowSchedulerConfiguration:
# Time zone
scheduleTimeZone: "UTC+8"
# Scheduling cycle time unit: day, hour
cycleStep: "1"
# Task dependency: parallel, unordered serial, ordered serial
selfDepend: "serial"
# Effective start time
startTime: "2024-01-29 00:00:00"
# Effective end time
endTime: "2099-12-31 23:59:59"
# Workflow dependency, yes or no
dependencyWorkflow: "no"
# Delay 50 minutes from 00:00 every day
delayTime: 50
# Specified runtime
taskAction: "taskAction"
# Execution time left closed interval
executionStartTime: "00:00"
# Execution time right closed interval
executionEndTime: "23:59"
# crontabExpression cron expression
crontabExpression: "0 0 3 * * ? *"
# cycleType
cycleType: "DAY_CYCLE"

2.2 任务

不同任务类型配置项不同,以下为一个 shell 任务的示例。其他任务类型可参考对应 OpenAPI。
特殊说明:For-each 节点、离线集成任务的脚本模式和 Notebook 节点当前版本暂不支持。
resources:
tasks:
taskResourceKey:
# Task name
name: taskName
# Wedata remote directory
remoteDirPath: Default/temp/
# Task script
filePath: "../../src/task/testJDBC.sql"
# Task basic attributes
taskBaseAttribute:
# Task type name
taskTypeName: shell
# Fill in the actual workflow name
workflowName: test_workflow
# Task description
taskDescription: taskDesc
# Task owner name
ownerName: ownerName
# Task configuration
taskConfiguration:
# Resource group name
resourceGroupName: test_worker_name
# Specifiable running node
brokerIp: "192.37.23.123"
# Task extension property configuration list
taskExtConfigurationList:
- paramKey: "specLabelConfItems" # Referenced resources, need clear documentation
paramValue: "[{\\"filePath\\": \\"/asherxu/ConstellationUDF.jar\\"}, {\\"filePath\\": \\"/dw/test.zip\\"}]"
- paramKey: "source_service"
paramValue: "Data source name"
- paramKey: "python_type"
paramValue: "python3"
- paramKey: "data_cluster"
paramValue: "engine data cluster name"
# Cluster name
dataClusterName: "clusterName"
# yarnQueue engine queue name
yarnQueue: "default"
# Source data source name for integration task
sourceServiceName: "sourceServiceName"
# Target data source name for integration task
targetServiceName: "targetServiceName"
# Scheduling parameters
taskSchedulingParameterList:
- paramKey: extraInfo # Parameter name
ParamValue: testVal # Parameter value
# Task scheduling configuration
taskSchedulerConfiguration:
# Cycle type
cycleType: DAY_CYCLE
# Time zone
scheduleTimeZone: UTC+8
# Effective date
startTime: "2025-08-26 00:00:00"
# End date
endTime: "2099-12-31 23:59:59"
# Execution time left closed interval
executionStartTime: "00:00"
# Execution time right closed interval
executionEndTime: "23:59"
# Scheduling type: 0 normal scheduling 1 dry run scheduling
scheduleRunType: 0
# Self-dependency
selfDepend: "serial"
# Upstream dependency array
upstreamDependencyConfigList:
- taskName: "Task name"
# Main dependency configuration
mainCyclicConfig: "DAY"
# Secondary dependency configuration
subordinateCyclicConfig: "CURRENT_DAY"
# Offset in interval or list mode
offset: "0,1"
# Dependency execution strategy
dependencyStrategy:
- pollingNullStrategy: EXECUTING # Waiting for upstream task instance strategy: EXECUTING (execute); WAITING (wait)
taskDependencyExecutingStrategies:
- "PARENT_TIMEOUT"
# Downstream task dependency on parent instance execution timeout
TaskDependencyExecutingTimeoutValue: "1"
# Event listener list
eventListenerList:
- eventName: "test_auto111" # Event name
eventSubType: "DAY"
propertiesList:
- paramKey: "paramKey"
paramValue: "paramValue"
eventBroadcastType: "BROADCAST"
# Task scheduling priority (low, middle, high)
runPriority: low
# Retry strategy retry wait time, unit minutes: default: 5
retryWait: 5
# Retry strategy maximum attempts, default: 4
maxRetryAttempts: 4
# Timeout handling strategy runtime timeout (unit: minutes) default is -1
ExecutionTTL: -1
# Timeout handling strategy total waiting time timeout (unit: minutes) default is -1
waitExecutionTotalTTL: -1
# Rerun & backfill configuration, default is ALL
allowRedoType: ALL
paramTaskOutLst:
- paramKey: "paramKey"
paramValue: "paramValue"
paramTaskInList:
- paramKey: "paramKey"
# Parameter description
paramDesc: "paramDesc"
# Parent task name
fromTaskName: "taskName"
# fromParamKey parent task parameter key
fromParamKey: "fromParamKey"
initStrategy: "T_PLUS_0"

2.3 资源文件

resources:
resourceFiles:
resourceFileResourceKey:
name: resourceFileName
# Wedata remote directory
remoteDirPath: /fd1/test/
# Parameter name
filePath: ../../src/resourceFile/datastudio-service-5.2.0.1.jar
# COS bucket name
bucketName: wedata-cos
# COS bucket region
cosRegion: ap-shanghai

2.4 项目参数

resources:
projectParams:
paramResourceKey:
# Parameter name key
name: paramName
# Parameter description
paramDescription: paramDescription
# Debug run value
paramDefineTest: dryRunVal
# Cycle scheduling value
paramDefine: scheduleRunVal

2.5 告警规则

resources:
alarms:
alarmResourceKey:
# Alarm name
name: alarmName
# Alarm rule description
description: description
# List of monitored object business names (task names)
monitorObjectNames:
- taskName1
- taskName2
# Monitor type: task, workflow, project
monitorObjectType: task
# Alarm type: 1.failure alarm, 2.timeout alarm, 3.success alarm, 4.baseline breach, 5.baseline warning, 6.baseline task failure, 7.alarm monitoring, alarm type code list (default 1.failure alarm)
alarmTypes:
- failAlarm
alarmGroups:
- alarmRecipientType: Task Owner # Alarm recipient type: 1.specified personnel, 2.task owner, 3.duty roster (default 1.specified personnel)
# Alarm level, 1.normal, 2.important, 3.urgent (default 1.normal)
alarmLevel: normal
# Alarm escalation user names
alarmEscalationRecipientNames:
- asherxu@tencent.com
# Alarm escalation interval
alarmEscalationInterval: 86400
# Alarm user names
alarmRecipientNames:
- asherxu@tencent.com
# Alarm methods: 1.email, 2.SMS, 3.WeChat, 4.voice, 5.WeCom, 6.Http, 7.WeCom group, 8.Feishu group (default 1.email)
alarmWays:
- email
webHooks:
alarmWay: "Teams"
webHooks: "http://open/group"
# Alarm notification frequency
notificationFatigue:
# Notification count (3 times)
notifyCount: 3
# Notification interval, in minutes
notifyInterval: 5
# Do not disturb time
quietIntervals:
- daysOfWeek: [ 1, 2 ] # Days of week
startTime: 02:00:00 # Start time, precise to hour, minute, second
endTime: 06:00:00 # End time, precise to hour, minute, second
- daysOfWeek: [ 3 ] # Days of week
startTime: 01:00:00 # Start time, precise to hour, minute, second
endTime: 05:00:00 # End time, precise to hour, minute, second

# Alarm rule details
alarmRuleDetail:
# Failure trigger timing 1 - First failure trigger 2 - All retries completed trigger (default)
trigger: 1
# Rerun/backfill failure trigger timing 1 - First failure trigger 2 - All retries completed trigger (default)
dataBackfillOrRerunTrigger: 1
# Timeout configuration details
timeOutExtInfo:
- ruleType: 1 # Timeout strategy: 1.estimated runtime, 2.estimated completion time, 3.estimated scheduling time, 4.not completed within cycle, 5.total waiting time, 6.waiting runtime
type: 1 # Timeout value type 1.specified value (default) 2.average value
hour: 1 # Timeout specified value hours (default 0)
min: 30 # Timeout specified value minutes (default 1)
scheduleTimeZone: UTC+7 # Configured timezone, defaults to project timezone
# Backfill/rerun timeout configuration details
dataBackfillOrRerunTimeOutExtInfo:
- ruleType: 1 # Timeout strategy: 1.estimated runtime, 2.estimated completion time, 3.estimated scheduling time, 4.not completed within cycle, 5.total waiting time, 6.waiting runtime
type: 1 # Timeout value type 1.specified value (default) 2.average value
hour: 1 # Timeout specified value hours (default 0)
min: 30 # Timeout specified value minutes (default 1)
scheduleTimeZone: UTC+7 # Configured timezone, defaults to project timezone
# Project fluctuation alarm configuration details
projectInstanceStatisticsAlarmInfoList:
alarmType: projectFailureInstanceUpwardFluctuationAlarm # Failed instance upward fluctuation alarm, successful instance downward fluctuation alarm
instanceThresholdCountPercent: 10 # Percentage of failed instances for the day
instanceThresholdCount: 20 # Total threshold: daily failed instances, daily cumulative instances, daily failed instances upward fluctuation, cumulative instances fluctuation threshold
instanceCount: 20 # Daily cumulative instances, daily failed instances downward fluctuation
stabilizeStatisticsCycle: 3 # Stability statistics cycle (anti-jitter configuration statistics cycle count)
isCumulate: false # Whether to calculate cumulatively, false: consecutive, true: cumulative
stabilizeThreshold: 3 # Stability count threshold (anti-jitter configuration statistics cycle count)
reconciliationExtInfo:
- ruleType: reconciliationFailure
mismatchCount: 1
hour: 1
min: 30

2.6 事件

resources:
events:
eventResourceKey:
name: eventName
# Types include: MIN, HOUR, DAY
eventSubType: MIN
# Optional, if not filled, use default user
ownerName: asherxu
# Event description
description: "description"
# Event time to live
timeToLive: 1
# Time to live unit: DAY, MIN
timeUnit: DAYS
# Event type: GENERAL, TIME_SERIES
eventType: "TIME_SERIES"
# Event broadcast type: SINGLE, BROADCAST
eventBroadcastType: "BROADCAST"
# Time format
dimensionFormat: "yyyymmdd"

3. src 文件

用于存储任务的代码信息和资源文件上传包。可在当前文件中进行任务代码变更或资源文件上传包变更。

bundle 命令

1. 安装&卸载客户端

1. 安装客户端。
功能:本地安装 WeData 客户端。
命令:
#Install the WeData client (no installation package required, simply run the program).
#macOS system installation
curl https://wedata-agent-gz-1257305158.cos.ap-guangzhou.myqcloud.com/bundle/install-script/linux/install.sh |sudo sh -s -- --region 'https://ap-guangzhou.wedata.cloud.tencent.com'
#windows system installation
curl.exe -fsSL https://wedata-agent-gz-1257305158.cos.ap-guangzhou.myqcloud.com/bundle/install-script/windows/install.bat -o install.bat && install.bat --region "https://ap-guangzhou.wedata.cloud.tencent.com"
2. 卸载客户端。
功能:本地卸载 WeData 客户端。
命令:
#Uninstall WeData client
#macOS system uninstallation
curl https://wedata-agent-gz-1257305158.cos.ap-guangzhou.myqcloud.com/bundle/install-script/linux/install.sh |sudo sh -s -- --uninstall
#windows system uninstallation
curl.exe -fsSL https://wedata-agent-gz-1257305158.cos.ap-guangzhou.myqcloud.com/bundle/install-script/windows/install.bat -o install.bat && install.bat --uninstall
3. 升级为最新版本。
功能:将当前安装的客户端版本升级为最高版本。
命令:
#Upgrade the currently installed client version to the latest version.
sudo sh install.sh --upgrade

#Update to the latest version
#Singapore area
#macOS system upgrade
curl https://wedata-agent-sg-1257305158.cos.ap-singapore.myqcloud.com/bundle/install-script/linux/install.sh |sudo sh -s -- --upgrade --region 'https://api-ap-singapore.wedata.tencentcloud.com'
#windows system upgrate
curl.exe -fsSL https://wedata-agent-sg-1257305158.cos.ap-singapore.myqcloud.com/bundle/install-script/windows/install.bat -o install.bat && install.bat --upgrade --region "https://api-ap-singapore.wedata.tencentcloud.com"
4. 获取安装版本。
功能:获取当前安装的 WeData 客户端版本。
命令:
#Get the currently installed client version
wedata -v
wedata--version

2. 登录

支持两种客户端登录方式:跳转产品登录验证、使用固定密钥登录。
1. 跳转产品登录验证。
第一步:本地终端输入登录页面,${workspace-url} 替换为需要登录账号下的任意项目内链接,链接中需要包含地域和项目 ID 信息。
#Both commands can be used to log in.
wedata auth login --host '${workspace-url}'
wedata auth login
第二步:定义登录 profile,输入登录项目 url 信息。
Please enter the new configuration file name (directly enter to use the current configuration): 这里输入 profile 名称。
Please enter the WeData project address: 若在命令中未指定项目 url,则需要在这里指定 url。
第三步:跳转到产品并登录。
完善登录命令信息后,若未在产品上登录则会跳转到登录页,您需完成登录。若已登录,则进入第三步。
第四步:首次登录需前往 访问管理 进行授权。
若为首次登录,需要按照页面指引前往访问管理模块进行授权。授权完毕后请返回登录页面并刷新页面重新验证。
2. 使用固定密钥登录。
可在访问管理中获取当前账号的 secret_id 和 secret_key ,可在 git 等产品上进行配置实现固定密钥登录。
说明:
使用跳转产品登录验证的方式,登录状态保留时间为12小时,超过12小时需重新登录。使用固定密钥方式,登录状态保留时间为永久。

3. 初始化

1. bundle init
功能:初始化一个 bundle 包,初始化的 bundle 包包含 wedata.yml 文件和资源文件。wedata.yml 文件包含 bundle 包的基础信息、target(用于定义不同环境对应项目)等信息。初始化资源可自行选择,可选工作流、任务、资源文件、项目参数、告警规则、事件,若选择则系统将默认初始化对应资源,您可按需修改资源配置。
命令:
#Initialize a bundle
wedata bundle init
2. bundle generate
功能:将项目中已经创建好的资源拉取到本地 bundle 包中。仅将资源拉取到本地,并不代表跟远端资源有绑定关系,若需有绑定关系则需执行绑定命令。
说明:若通过 git 绑定方式创建的任务,则 generate 时只获取配置,不获取代码内容,代码内容改动依赖客户指定的 git 路径。
-t:目标环境。
-p:指定执行命令的profile。
#Bundle initialization related commands
wedata bundle generate task --existing-task-id ${task_id} -t dev/prod -p profile_name
wedata bundle generate workflow --existing-workflow-id ${workflow_id} -t dev/prod -p profile_name
wedata bundle generate event --existing-event-id ${event_id} -t dev/prod -p profile_name
wedata bundle generate alarm --existing-alarm-id ${alarm_id} -t dev/prod -p profile_name
wedata bundle generate resourceFile --existing-resourceFile-id ${resourceFile_id} -t dev/prod -p profile_name
wedata bundle generate projectParam --existing-projectParam-name ${projectParam_name} -t dev/prod -p profile_name

4. 绑定与解绑

1. bundle deployment bind
功能:将 generate 的资源与当前 bundle 包绑定,绑定后,在本地修改的能力将同步到远端。
-t:目标环境。
-p:指定执行命令的 profile。
命令:
#Resources are bound to local bundles
wedata bundle deployment bind task ${resource key} ${task_id} -t dev/prod -p profile_name
wedata bundle deployment bind workflow ${resource key} ${workflow_id} -t dev/prod -p profile_name
wedata bundle deployment bind event ${resource key} ${event_id} -t dev/prod -p profile_name
wedata bundle deployment bind alarm ${resource key} ${alarm_id} -t dev/prod -p profile_name
wedata bundle deployment bind resourceFile ${resource key} ${resourceFile_id} -t dev/prod -p profile_name
wedata bundle deployment bind projectParam ${resource key} ${projectParam_name} -t dev/prod -p profile_name
2. bundle deployment unbind
功能:解除资源与本地 bundle 包的绑定关系。
-t:目标环境。
-p:指定执行命令的 profile。
命令:
#Unbind resources from local bundle
wedata bundle deployment unbind task ${resource key} -t dev/prod -p profile_name
wedata bundle deployment unbind workflow ${resource key} -t dev/prod -p profile_name
wedata bundle deployment unbind event ${resource key} -t dev/prod -p profile_name
wedata bundle deployment unbind alarm ${resource key} -t dev/prod -p profile_name
wedata bundle deployment unbind resourceFile ${resource key} -t dev/prod -p profile_name
wedata bundle deployment unbind wedataStudio ${resource key} -t dev/prod -p profile_name
wedata bundle deployment unbind projectParam ${resource key} -t dev/prod -p profile_name

5. 运行

功能:运行某个任务或某个工作流下的所有任务,执行运行情况和结果可在编排空间中查看。
-t:目标环境。
-p:指定执行命令的 profile。
命令:
wedata bundle run task ${resource key} -t dev/prod -p profile_name #Run a specific task
wedata bundle run workflow ${resource key} -t dev/prod -p profile_name #Run a specific workflow

6. 验证

功能:验证 bundle 包及其资源配置是否存在问题。可在部署前提前验证,提前发现问题并处理问题。
-t:目标环境。
-p:指定执行命令的 profile。
wedata bundle validate -t dev/prod -p profile_name #Verify bundle and resource configuration

7. 部署

功能:将 bundle包中的内容部署到目标环境。
-t:目标环境。
-p:指定执行命令的 profile。
-s:变更是否提交到调度。值为 true/false,true 表示提交到调度,false 表示仅保存编排空间保存版本。
命令:
wedata bundle deploy -t dev/prod -p profile_name -s true # Deploy the contents of the bundle to the corresponding environment

8. 销毁

功能:删除远端绑定的任务,并删除在远端存储的 bundle 包及资源信息。
-t:目标环境。
-p:指定执行命令的 profile。
命令:
wedata bundle destroy -t dev/prod -p profile_name #Destroy the contents deployed via bundle in the corresponding environment.

9. 总结

功能:获取当前 bundle 包中包含的资源信息。
-t:目标环境。
命令:
wedata bundle summary #Summary of the current package binding task status

10. 帮助

功能:获取帮助信息,即 bundle 命令的使用规则和帮助信息。
命令:
wedata bundle -help # Display command help information