feat: 精简发布确认并支持回滚和助手操作
- 删除三个留档必填项与重复检查卡片,提交前核对真实锁定版本。 - 增加待确认操作卡片、发布回执与历史成功版本回滚入口,保护会话隔离和迟到响应。 - 折叠助手来源并清理系统设置的无效实现提示,保留并行通知配置改动。
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
- **项目 `/overview`**:单行项目列表,部署中的排在前面;仅保留部署状态、环境/版本、时间和日志入口。支持部署中、最近失败与项目搜索。
|
- **项目 `/overview`**:单行项目列表,部署中的排在前面;仅保留部署状态、环境/版本、时间和日志入口。支持部署中、最近失败与项目搜索。
|
||||||
- **记录 `/runs`**:按项目、环境、状态和关键词查询,每页 20 条。打开记录抽屉后查看步骤、统一输出和 Jenkins 日志。
|
- **记录 `/runs`**:按项目、环境、状态和关键词查询,每页 20 条。打开记录抽屉后查看步骤、统一输出和 Jenkins 日志。
|
||||||
- **助手**:首页直接提问,或从顶部打开右侧抽屉。可问最近部署、纳管项目、构建结果及失败原因;后端模型自主调用只读工具,回答附来源。
|
- **助手**:首页直接提问,或从顶部打开右侧抽屉。可问最近部署、纳管项目、构建结果及失败原因;后端模型查询事实并准备发布、回滚、取消和重试计划;回答附来源,操作必须核对后点击确认执行。
|
||||||
- **更多功能**:发布、接入、成员权限和设置统一收进顶部菜单。生产发布保留确认要求,权限由后端校验。
|
- **更多功能**:发布、接入、成员权限和设置统一收进顶部菜单。生产发布保留确认要求,权限由后端校验。
|
||||||
|
|
||||||
登录由后端识别角色,无需先选择管理员或成员。原有 `/releases`、`/projects`、`/members`、`/settings` 链接保留。
|
登录由后端识别角色,无需先选择管理员或成员。原有 `/releases`、`/projects`、`/members`、`/settings` 链接保留。
|
||||||
@@ -61,6 +61,8 @@ npm run build
|
|||||||
|
|
||||||
前端不直连 Jenkins、Gitea、通知或模型供应商。发布步骤来源为服务端 `run.steps`,统一以 `nodeId` 定位;状态机、权限、幂等、审计和脱敏由后端负责。
|
前端不直连 Jenkins、Gitea、通知或模型供应商。发布步骤来源为服务端 `run.steps`,统一以 `nodeId` 定位;状态机、权限、幂等、审计和脱敏由后端负责。
|
||||||
|
|
||||||
运维助手限于 DevOps,只提供查询与分析;发布、取消、重试仍通过明确操作与权限检查执行。
|
运维助手限于 DevOps。模型不能执行任意命令或直接触发部署;操作卡片由后端签名,绑定操作者、具体提交和 10 分钟有效期,确认时重新检查权限与环境状态。历史问答中的计划不可直接执行。
|
||||||
|
|
||||||
|
发布页只保留目标版本和生产确认。发布记录中的“回滚到此版本”会重新构建历史成功记录的精确提交;回滚不撤销数据库迁移或外部数据。流水线需支持 `DEPLOY_COMMIT`,无法核实历史 SHA 时明确拒绝。
|
||||||
|
|
||||||
MIT License。环境文件与真实凭据不得进入 Git。
|
MIT License。环境文件与真实凭据不得进入 Git。
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
技术栈保持 Vue 3 + Vite + TypeScript + Element Plus + Pinia。所有业务数据统一经后端 API,不提供前端业务 mock 降级。
|
技术栈保持 Vue 3 + Vite + TypeScript + Element Plus + Pinia。所有业务数据统一经后端 API,不提供前端业务 mock 降级。
|
||||||
|
|
||||||
- `/overview`:精简项目列表,部署中优先,直接查看日志;首页可以向只读助手提问。
|
- `/overview`:精简项目列表,部署中优先,直接查看日志;首页可以向运维助手提问。
|
||||||
- `/runs?projectKey=…&environment=…&status=…&q=…&page=…&runId=…`:查询、分页、步骤与日志抽屉。
|
- `/runs?projectKey=…&environment=…&status=…&q=…&page=…&runId=…`:查询、分页、步骤与日志抽屉。
|
||||||
- 顶部助手:真实远程模型通过后端自主调用只读工具;回答显示真实来源。没有独立侧栏页面或泛聊天能力。
|
- 顶部助手:真实远程模型通过后端查询并准备操作计划,用户确认后由后端执行;回答显示真实来源。没有独立侧栏页面或泛聊天能力。
|
||||||
- 顶部更多菜单:`/releases`、`/projects`、`/members`、`/settings` 保留,管理路由继续按权限保护。
|
- 顶部更多菜单:`/releases`、`/projects`、`/members`、`/settings` 保留,管理路由继续按权限保护。
|
||||||
- `/settings?tab=integrations|notifications|audit|agent`:集成、通知、审计、模型配置。
|
- `/settings?tab=integrations|notifications|audit|agent`:集成、通知、审计、模型配置。
|
||||||
- `/login`:统一登录;角色由后端识别;保留首次改密。
|
- `/login`:统一登录;角色由后端识别;保留首次改密。
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 极简部署与只读 Agent 验证
|
# 极简部署与确认操作验证
|
||||||
|
|
||||||
本记录说明上线前的验证范围。生产发布由现有 Gitea master webhook → Jenkins → 部署脚本执行,实际结果以目标构建和线上接口验收为准。
|
本记录说明上线前的验证范围。生产发布由现有 Gitea master webhook → Jenkins → 部署脚本执行,实际结果以目标构建和线上接口验收为准。
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
## 自动化
|
## 自动化
|
||||||
|
|
||||||
- 前端 `npm test`:12 项回归,覆盖请求、排序、权限、迟到请求和有界助手上下文。
|
- 前端 `npm test`:14 项回归,覆盖请求、排序、权限、迟到请求和有界助手上下文。
|
||||||
- 前端 `npm run build`:TypeScript 与 Vite 生产构建。
|
- 前端 `npm run build`:TypeScript 与 Vite 生产构建。
|
||||||
- 后端 `npm run lint`、`npm test -- --runInBand`、`npm run prisma:generate`、`npm run build`。
|
- 后端 `npm run lint`、`npm test -- --runInBand`、`npm run prisma:generate`、`npm run build`。
|
||||||
- 后端回归额外覆盖只读工具、授权范围、模型循环/并发上限、流式读取大小、密钥脱敏和个人历史隔离。
|
- 后端回归额外覆盖只读工具、授权范围、模型循环/并发上限、流式读取大小、密钥脱敏和个人历史隔离。
|
||||||
@@ -28,3 +28,9 @@ Vite 仍有依赖内部 `@vueuse/core` 的两条 PURE annotation 提示,不阻
|
|||||||
- 生产已验证真实数据库问答、持久化来源,以及 API #62 / Web #45 成功构建;后续轻量发现与公开构建链接补丁仍需按各自目标构建验收。
|
- 生产已验证真实数据库问答、持久化来源,以及 API #62 / Web #45 成功构建;后续轻量发现与公开构建链接补丁仍需按各自目标构建验收。
|
||||||
|
|
||||||
服务器基线:约 3.7GB 总内存、约 1.4GB 可用,API RSS 约 110MB。API 与 Web 顺序部署,避免同时构建。
|
服务器基线:约 3.7GB 总内存、约 1.4GB 可用,API RSS 约 110MB。API 与 Web 顺序部署,避免同时构建。
|
||||||
|
|
||||||
|
## 本轮确认操作
|
||||||
|
|
||||||
|
移除回滚方案、发布窗口、通知对象三个留档必填项,以及重复的发布检查卡片。Agent 来源默认折叠,系统设置移除“等待后端说明”等实现提示。
|
||||||
|
|
||||||
|
新增签名操作计划和真实历史提交回滚,模型只准备,用户核对后执行。单元验证覆盖过期、篡改、跨账号、权限撤销、环境漂移、幂等、并发、精确提交与历史令牌去除;流水线升级脚本保留参数选择器,并通过 Jenkins Declarative 校验。本轮生产结果与实际操作回执在发布验收时另行核实。
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import OperationPlanCard from './OperationPlanCard.vue'
|
||||||
import { Close, Promotion, Plus } from '@element-plus/icons-vue'
|
import { Close, Promotion, Plus } from '@element-plus/icons-vue'
|
||||||
import { nextTick, onMounted, ref, watch } from 'vue'
|
import { nextTick, onMounted, ref, watch } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
@@ -84,7 +85,7 @@ function keydown(event: KeyboardEvent) {
|
|||||||
<template>
|
<template>
|
||||||
<aside class="agent-drawer">
|
<aside class="agent-drawer">
|
||||||
<header class="agent-header">
|
<header class="agent-header">
|
||||||
<div><strong>运维助手</strong><span>查项目、部署和构建,回答附来源</span></div>
|
<div><strong>运维助手</strong><span>查询状态,准备发布与回滚计划</span></div>
|
||||||
<ElButton text :icon="Close" aria-label="关闭运维助手" @click="emit('close')" />
|
<ElButton text :icon="Close" aria-label="关闭运维助手" @click="emit('close')" />
|
||||||
</header>
|
</header>
|
||||||
<div class="agent-scope">
|
<div class="agent-scope">
|
||||||
@@ -135,7 +136,7 @@ function keydown(event: KeyboardEvent) {
|
|||||||
<div ref="messageList" class="message-list" aria-live="polite" aria-relevant="additions">
|
<div ref="messageList" class="message-list" aria-live="polite" aria-relevant="additions">
|
||||||
<div v-if="!assistant.messages.length" class="assistant-welcome">
|
<div v-if="!assistant.messages.length" class="assistant-welcome">
|
||||||
<h2>想了解什么?</h2>
|
<h2>想了解什么?</h2>
|
||||||
<p>直接提问,助手会按需读取你有权限的记录。</p>
|
<p>可查询,也可要求发布、回滚、取消或重试;操作需核对确认。</p>
|
||||||
<button
|
<button
|
||||||
v-for="question in suggestions"
|
v-for="question in suggestions"
|
||||||
:key="question"
|
:key="question"
|
||||||
@@ -156,7 +157,13 @@ function keydown(event: KeyboardEvent) {
|
|||||||
message.role === 'user' ? '你' : message.status === 'failed' ? '查询未完成' : '运维助手'
|
message.role === 'user' ? '你' : message.status === 'failed' ? '查询未完成' : '运维助手'
|
||||||
}}</strong>
|
}}</strong>
|
||||||
<p>{{ message.content }}</p>
|
<p>{{ message.content }}</p>
|
||||||
<details v-if="message.sources?.length" class="sources" open>
|
<OperationPlanCard
|
||||||
|
v-for="plan in message.operationPlans || []"
|
||||||
|
:key="plan.id"
|
||||||
|
:plan="plan"
|
||||||
|
@navigate="emit('close')"
|
||||||
|
/>
|
||||||
|
<details v-if="message.sources?.length" class="sources">
|
||||||
<summary>本次查询来源 · {{ message.sources.length }}</summary>
|
<summary>本次查询来源 · {{ message.sources.length }}</summary>
|
||||||
<template v-for="source in message.sources" :key="source.id"
|
<template v-for="source in message.sources" :key="source.id"
|
||||||
><a
|
><a
|
||||||
@@ -209,7 +216,7 @@ function keydown(event: KeyboardEvent) {
|
|||||||
@keydown="keydown"
|
@keydown="keydown"
|
||||||
/>
|
/>
|
||||||
<div class="composer-footer">
|
<div class="composer-footer">
|
||||||
<span>只读查询 · ⌘ / Ctrl + Enter</span
|
<span>操作需确认 · ⌘ / Ctrl + Enter</span
|
||||||
><ElButton
|
><ElButton
|
||||||
type="primary"
|
type="primary"
|
||||||
:icon="Promotion"
|
:icon="Promotion"
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { confirmOperation } from '../services/operationConfirmation'
|
||||||
|
import { usePlatformStore } from '../stores/platform'
|
||||||
|
import type { OperationPlan, ReleaseRun } from '../types/devops'
|
||||||
|
const props = defineProps<{ plan: OperationPlan }>()
|
||||||
|
const emit = defineEmits<{ navigate: [] }>()
|
||||||
|
const platform = usePlatformStore()
|
||||||
|
const executing = ref(false)
|
||||||
|
const error = ref('')
|
||||||
|
const receipt = ref<ReleaseRun>()
|
||||||
|
async function execute() {
|
||||||
|
if (executing.value || receipt.value) return
|
||||||
|
executing.value = true
|
||||||
|
error.value = ''
|
||||||
|
try {
|
||||||
|
if (!(await confirmOperation(props.plan))) return
|
||||||
|
receipt.value = await platform.executeOperation(props.plan.confirmationToken!)
|
||||||
|
if (receipt.value.status === 'failed') error.value = '操作未成功,请查看发布日志。'
|
||||||
|
else ElMessage.success('操作已提交,可查看实际进度与日志')
|
||||||
|
} catch (value) {
|
||||||
|
error.value = value instanceof Error ? value.message : '操作失败,请重试'
|
||||||
|
} finally {
|
||||||
|
executing.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<section class="operation-plan" :aria-busy="executing">
|
||||||
|
<strong
|
||||||
|
>{{ plan.title }} · {{ plan.projectKey }} ·
|
||||||
|
{{ plan.environment === 'production' ? '生产' : '测试' }}</strong
|
||||||
|
>
|
||||||
|
<p class="mono">
|
||||||
|
{{ plan.ref }}<span v-if="plan.commit"> @ {{ plan.commit.slice(0, 12) }}</span>
|
||||||
|
</p>
|
||||||
|
<p v-if="!receipt && plan.confirmationToken" class="field-hint">
|
||||||
|
尚未执行,确认后提交。计划有效期 10 分钟。
|
||||||
|
</p>
|
||||||
|
<p v-if="!plan.confirmationToken" class="field-hint">历史计划不能直接执行,请重新提问生成。</p>
|
||||||
|
<p v-if="plan.kind === 'rollback'" class="field-hint">回滚代码,不回滚数据库和外部数据。</p>
|
||||||
|
<p v-if="error" class="inline-error" role="alert">{{ error }}</p>
|
||||||
|
<RouterLink
|
||||||
|
v-if="receipt"
|
||||||
|
class="text-link"
|
||||||
|
:to="{ name: 'runs', query: { runId: receipt.id } }"
|
||||||
|
@click="emit('navigate')"
|
||||||
|
>{{ receipt.status === 'failed' ? '查看失败日志' : '查看执行进度与日志' }} →</RouterLink
|
||||||
|
>
|
||||||
|
<ElButton
|
||||||
|
v-else-if="plan.confirmationToken"
|
||||||
|
type="primary"
|
||||||
|
:loading="executing"
|
||||||
|
:disabled="executing || !platform.canBuildProject(plan.projectKey)"
|
||||||
|
@click="execute"
|
||||||
|
>核对并{{ plan.title }}</ElButton
|
||||||
|
>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
<style scoped>
|
||||||
|
.operation-plan {
|
||||||
|
margin: 16px 0;
|
||||||
|
padding: 16px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--surface, #fff);
|
||||||
|
}
|
||||||
|
.operation-plan p {
|
||||||
|
margin: 9px 0;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
.operation-plan strong {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
import type {
|
import type {
|
||||||
AgentCard,
|
AgentCard,
|
||||||
|
OperationPlan,
|
||||||
|
PrepareOperationPayload,
|
||||||
AgentQuestionPayload,
|
AgentQuestionPayload,
|
||||||
AgentConfigSummary,
|
AgentConfigSummary,
|
||||||
AgentConnectionTestResult,
|
AgentConnectionTestResult,
|
||||||
@@ -111,6 +113,9 @@ interface BackendDeployRun {
|
|||||||
environment?: EnvironmentName
|
environment?: EnvironmentName
|
||||||
ref?: string
|
ref?: string
|
||||||
status?: BackendRunStatus
|
status?: BackendRunStatus
|
||||||
|
resolvedCommit?: string
|
||||||
|
operationKind?: 'deploy' | 'rollback' | 'retry'
|
||||||
|
sourceRunId?: string
|
||||||
trigger?: 'manual' | 'gitea_webhook' | 'retry' | 'jenkins_external'
|
trigger?: 'manual' | 'gitea_webhook' | 'retry' | 'jenkins_external'
|
||||||
operator?: string
|
operator?: string
|
||||||
jenkinsQueueId?: string | number
|
jenkinsQueueId?: string | number
|
||||||
@@ -423,6 +428,15 @@ export const devopsApi = {
|
|||||||
return (await fetchRuns()).map((run) => toReleaseRun(run, projectList))
|
return (await fetchRuns()).map((run) => toReleaseRun(run, projectList))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async prepareOperation(payload: PrepareOperationPayload): Promise<OperationPlan> {
|
||||||
|
const { data } = await http.post<OperationPlan>('/operations/prepare', payload, {timeout: 45_000})
|
||||||
|
return data
|
||||||
|
},
|
||||||
|
async executeOperation(confirmationToken: string, projectList: ProjectConfig[]): Promise<ReleaseRun> {
|
||||||
|
const { data } = await http.post<{run:BackendDeployRun}>('/operations/execute', {confirmationToken,confirmed:true}, {timeout:45_000})
|
||||||
|
return toReleaseRun(data.run,projectList)
|
||||||
|
},
|
||||||
|
|
||||||
async createDeployRun(
|
async createDeployRun(
|
||||||
payload: CreateDeployRunPayload,
|
payload: CreateDeployRunPayload,
|
||||||
projectList: ProjectConfig[] = [],
|
projectList: ProjectConfig[] = [],
|
||||||
@@ -1076,6 +1090,9 @@ function toReleaseRun(run: BackendDeployRun, projectList: ProjectConfig[]): Rele
|
|||||||
jenkinsBuildNumber: run.jenkinsBuildNumber,
|
jenkinsBuildNumber: run.jenkinsBuildNumber,
|
||||||
jenkinsBuildUrl: run.jenkinsBuildUrl,
|
jenkinsBuildUrl: run.jenkinsBuildUrl,
|
||||||
jenkinsSummary: formatJenkinsBuild(run),
|
jenkinsSummary: formatJenkinsBuild(run),
|
||||||
|
resolvedCommit: run.resolvedCommit,
|
||||||
|
operationKind: run.operationKind,
|
||||||
|
sourceRunId: run.sourceRunId,
|
||||||
commitSummary: ref === '-' ? trigger : `${ref} · ${trigger}`,
|
commitSummary: ref === '-' ? trigger : `${ref} · ${trigger}`,
|
||||||
steps: (Array.isArray(run.steps) ? run.steps : [])
|
steps: (Array.isArray(run.steps) ? run.steps : [])
|
||||||
.slice()
|
.slice()
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { ElMessageBox } from 'element-plus'
|
||||||
|
import type { OperationPlan } from '../types/devops'
|
||||||
|
|
||||||
|
/** 只展示服务端核实的目标,不使用模型文本执行操作。 */
|
||||||
|
export async function confirmOperation(plan: OperationPlan): Promise<boolean> {
|
||||||
|
if (!plan.confirmationToken || Date.parse(plan.expiresAt) <= Date.now())
|
||||||
|
throw new Error('操作计划已过期,请重新生成')
|
||||||
|
const environment = plan.environment === 'production' ? '生产' : '测试'
|
||||||
|
const message = `${plan.projectKey} / ${environment}\n目标版本:${plan.ref}${plan.commit ? `\n锁定提交:${plan.commit}` : ''}${plan.kind === 'rollback' ? '\n将重新构建并部署此历史提交;数据库与外部数据不会随代码回滚。' : ''}`
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
message,
|
||||||
|
`确认${plan.title}${environment === '生产' ? '到生产环境' : ''}`,
|
||||||
|
{
|
||||||
|
confirmButtonText: `确认${plan.title}`,
|
||||||
|
cancelButtonText: '返回',
|
||||||
|
type: 'warning',
|
||||||
|
autofocus: false,
|
||||||
|
customClass: 'operation-confirmation',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
if (error === 'cancel' || error === 'close') return false
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { devopsApi } from '../services/devopsApi'
|
import { devopsApi } from '../services/devopsApi'
|
||||||
import type { AgentInvocation, AgentSource, AgentToolTrace } from '../types/devops'
|
import type { AgentInvocation, AgentSource, AgentToolTrace, OperationPlan } from '../types/devops'
|
||||||
|
|
||||||
export type AssistantMessage = {
|
export type AssistantMessage = {
|
||||||
id: string
|
id: string
|
||||||
@@ -10,6 +10,7 @@ export type AssistantMessage = {
|
|||||||
status: 'success' | 'failed'
|
status: 'success' | 'failed'
|
||||||
sources?: AgentSource[]
|
sources?: AgentSource[]
|
||||||
tools?: AgentToolTrace[]
|
tools?: AgentToolTrace[]
|
||||||
|
operationPlans?: OperationPlan[]
|
||||||
}
|
}
|
||||||
export const useAssistantStore = defineStore('assistant', () => {
|
export const useAssistantStore = defineStore('assistant', () => {
|
||||||
const isOpen = ref(false)
|
const isOpen = ref(false)
|
||||||
@@ -83,6 +84,7 @@ export const useAssistantStore = defineStore('assistant', () => {
|
|||||||
status: result.status === 'success' ? 'success' : 'failed',
|
status: result.status === 'success' ? 'success' : 'failed',
|
||||||
sources: result.sources,
|
sources: result.sources,
|
||||||
tools: result.toolExecutions,
|
tools: result.toolExecutions,
|
||||||
|
operationPlans: result.operationPlans,
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (current !== generation) return
|
if (current !== generation) return
|
||||||
@@ -127,6 +129,7 @@ export const useAssistantStore = defineStore('assistant', () => {
|
|||||||
status: record.status === 'success' ? 'success' : 'failed',
|
status: record.status === 'success' ? 'success' : 'failed',
|
||||||
sources: record.sources,
|
sources: record.sources,
|
||||||
tools: record.toolExecutions,
|
tools: record.toolExecutions,
|
||||||
|
operationPlans: record.operationPlans,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,13 @@ export const usePlatformStore = defineStore('platform', () => {
|
|||||||
integrationConfig.value = { checkedAt: '', integrations: [] }
|
integrationConfig.value = { checkedAt: '', integrations: [] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function executeOperation(confirmationToken: string) {
|
||||||
|
const currentGeneration = generation
|
||||||
|
const run = await devopsApi.executeOperation(confirmationToken, projects.value)
|
||||||
|
if (currentGeneration === generation) upsertRun(run)
|
||||||
|
return run
|
||||||
|
}
|
||||||
|
|
||||||
async function createDeployRun(payload: CreateDeployRunPayload) {
|
async function createDeployRun(payload: CreateDeployRunPayload) {
|
||||||
const currentGeneration = generation
|
const currentGeneration = generation
|
||||||
const run = await devopsApi.createDeployRun(payload, projects.value)
|
const run = await devopsApi.createDeployRun(payload, projects.value)
|
||||||
@@ -434,6 +441,7 @@ export const usePlatformStore = defineStore('platform', () => {
|
|||||||
canBuildProject,
|
canBuildProject,
|
||||||
loadAll,
|
loadAll,
|
||||||
createDeployRun,
|
createDeployRun,
|
||||||
|
executeOperation,
|
||||||
cancelDeployRun,
|
cancelDeployRun,
|
||||||
retryDeployRun,
|
retryDeployRun,
|
||||||
syncJenkinsRun,
|
syncJenkinsRun,
|
||||||
|
|||||||
@@ -337,3 +337,5 @@ a {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.operation-confirmation .el-message-box__message { white-space: pre-line; overflow-wrap: anywhere; }
|
||||||
|
|||||||
@@ -373,6 +373,9 @@ export interface ReleaseRun {
|
|||||||
jenkinsBuildUrl?: string
|
jenkinsBuildUrl?: string
|
||||||
jenkinsSummary?: string
|
jenkinsSummary?: string
|
||||||
commitSummary: string
|
commitSummary: string
|
||||||
|
resolvedCommit?: string
|
||||||
|
operationKind?: 'deploy' | 'rollback' | 'retry'
|
||||||
|
sourceRunId?: string
|
||||||
steps: PipelineStep[]
|
steps: PipelineStep[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -532,6 +535,7 @@ export interface AgentInvocation {
|
|||||||
sources?: AgentSource[]
|
sources?: AgentSource[]
|
||||||
toolExecutions?: AgentToolTrace[]
|
toolExecutions?: AgentToolTrace[]
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
operationPlans?: OperationPlan[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateAgentInvocationPayload {
|
export interface CreateAgentInvocationPayload {
|
||||||
@@ -561,3 +565,21 @@ export interface AgentConnectionTestResult {
|
|||||||
message: string
|
message: string
|
||||||
checkedAt: string
|
checkedAt: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OperationPlan {
|
||||||
|
id: string
|
||||||
|
kind: 'deploy' | 'rollback' | 'cancel' | 'retry'
|
||||||
|
title: string
|
||||||
|
projectKey: string
|
||||||
|
environment: EnvironmentName
|
||||||
|
ref: string
|
||||||
|
commit?: string
|
||||||
|
sourceRunId?: string
|
||||||
|
baselineRunId?: string
|
||||||
|
expiresAt: string
|
||||||
|
confirmationToken?: string
|
||||||
|
}
|
||||||
|
export type PrepareOperationPayload =
|
||||||
|
| { kind: 'deploy'; projectKey: string; environment: EnvironmentName; ref?: string }
|
||||||
|
| { kind: 'rollback'; projectKey?: string; environment?: EnvironmentName; runId?: string }
|
||||||
|
| { kind: 'cancel' | 'retry'; runId: string }
|
||||||
|
|||||||
+39
-120
@@ -1,24 +1,30 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, reactive, ref, watch } from 'vue'
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { Promotion, Refresh } from '@element-plus/icons-vue'
|
import { Promotion, Refresh } from '@element-plus/icons-vue'
|
||||||
|
import { devopsApi } from '../services/devopsApi'
|
||||||
|
import { confirmOperation } from '../services/operationConfirmation'
|
||||||
import StatusPill from '../components/StatusPill.vue'
|
import StatusPill from '../components/StatusPill.vue'
|
||||||
import { usePlatformStore } from '../stores/platform'
|
import { usePlatformStore } from '../stores/platform'
|
||||||
import { formatTime } from '../utils/releases'
|
import { formatTime } from '../utils/releases'
|
||||||
import type { EnvironmentName } from '../types/devops'
|
import type { EnvironmentName, OperationPlan } from '../types/devops'
|
||||||
|
|
||||||
const platform = usePlatformStore()
|
const platform = usePlatformStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const form = reactive({ projectKey: '', environment: 'test' as EnvironmentName, ref: '', note: '' })
|
const form = reactive({
|
||||||
const confirmation = reactive({ rollback: '', window: '', notify: '', reviewed: false })
|
projectKey: '',
|
||||||
|
environment: 'test' as EnvironmentName,
|
||||||
|
ref: '',
|
||||||
|
})
|
||||||
|
const confirmation = reactive({ reviewed: false })
|
||||||
const submitting = ref(false)
|
const submitting = ref(false)
|
||||||
const refsLoading = ref(false)
|
const refsLoading = ref(false)
|
||||||
const refsError = ref('')
|
const refsError = ref('')
|
||||||
const submittedRunId = ref('')
|
const submittedRunId = ref('')
|
||||||
let refsRequest = 0
|
let refsRequest = 0
|
||||||
let requestKey = ''
|
let preparedPlan: OperationPlan | undefined
|
||||||
const selectedProject = computed(() =>
|
const selectedProject = computed(() =>
|
||||||
platform.projects.find((project) => project.key === form.projectKey),
|
platform.projects.find((project) => project.key === form.projectKey),
|
||||||
)
|
)
|
||||||
@@ -40,54 +46,25 @@ const latestRun = computed(() =>
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
const submittedRun = computed(() => platform.runs.find((run) => run.id === submittedRunId.value))
|
const submittedRun = computed(() => platform.runs.find((run) => run.id === submittedRunId.value))
|
||||||
const productionReady = computed(
|
const productionReady = computed(() => form.environment !== 'production' || confirmation.reviewed)
|
||||||
() =>
|
|
||||||
form.environment !== 'production' ||
|
|
||||||
(confirmation.reviewed &&
|
|
||||||
confirmation.rollback.trim() &&
|
|
||||||
confirmation.window.trim() &&
|
|
||||||
confirmation.notify.trim()),
|
|
||||||
)
|
|
||||||
const disabledReason = computed(() => {
|
const disabledReason = computed(() => {
|
||||||
if (!selectedProject.value || !selectedEnvironment.value) return '请选择项目与发布环境'
|
if (!selectedProject.value || !selectedEnvironment.value) return '请选择项目与发布环境'
|
||||||
if (!platform.canBuildProject(form.projectKey)) return '当前项目为只读权限,请联系管理员授权'
|
if (!platform.canBuildProject(form.projectKey)) return '当前项目为只读权限,请联系管理员授权'
|
||||||
if (!selectedEnvironment.value.jenkinsJob) return '当前环境尚未配置构建任务'
|
if (!selectedEnvironment.value.jenkinsJob) return '当前环境尚未配置构建任务'
|
||||||
if (refsLoading.value) return '正在读取可发布版本…'
|
if (refsLoading.value) return '正在读取可发布版本…'
|
||||||
if (refsError.value) return '版本读取失败,请重试'
|
if (refsError.value) return '版本读取失败,请重试'
|
||||||
|
if (refs.value?.source !== 'gitea') return '无法实时核对版本,请检查仓库接入后重试'
|
||||||
if (!refOptions.value.length)
|
if (!refOptions.value.length)
|
||||||
return useTags.value
|
return useTags.value
|
||||||
? '暂无可发布标签,请先在仓库创建版本标签'
|
? '暂无可发布标签,请先在仓库创建版本标签'
|
||||||
: '暂无可发布分支,请检查仓库接入'
|
: '暂无可发布分支,请检查仓库接入'
|
||||||
if (!selectedRef.value) return `请选择${useTags.value ? '版本标签' : '分支'}`
|
if (!selectedRef.value) return `请选择${useTags.value ? '版本标签' : '分支'}`
|
||||||
if (!productionReady.value) return '请填写生产确认信息并勾选核对项'
|
if (!productionReady.value) return '请核对目标版本并确认生产发布'
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
const checks = computed(() => [
|
|
||||||
{
|
|
||||||
title: '操作权限',
|
|
||||||
text: platform.canBuildProject(form.projectKey) ? '可发布' : '只读',
|
|
||||||
state: platform.canBuildProject(form.projectKey) ? ('healthy' as const) : ('error' as const),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '版本来源',
|
|
||||||
text:
|
|
||||||
refs.value?.source === 'gitea'
|
|
||||||
? 'Gitea 实时读取'
|
|
||||||
: refs.value
|
|
||||||
? '后端备用版本,请复核'
|
|
||||||
: '尚未读取',
|
|
||||||
state: refs.value?.source === 'gitea' ? ('healthy' as const) : ('warning' as const),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '构建任务',
|
|
||||||
text: selectedEnvironment.value?.jenkinsJob || '未配置',
|
|
||||||
state: selectedEnvironment.value?.jenkinsStatus || ('warning' as const),
|
|
||||||
},
|
|
||||||
])
|
|
||||||
|
|
||||||
function resetConfirmation() {
|
function resetConfirmation() {
|
||||||
confirmation.reviewed = false
|
confirmation.reviewed = false
|
||||||
requestKey = ''
|
preparedPlan = undefined
|
||||||
}
|
}
|
||||||
function applyRoute() {
|
function applyRoute() {
|
||||||
const projectKey = typeof route.query.projectKey === 'string' ? route.query.projectKey : ''
|
const projectKey = typeof route.query.projectKey === 'string' ? route.query.projectKey : ''
|
||||||
@@ -147,10 +124,7 @@ watch(
|
|||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
watch(
|
watch(() => [form.ref], resetConfirmation)
|
||||||
() => [form.ref, form.note, confirmation.rollback, confirmation.window, confirmation.notify],
|
|
||||||
resetConfirmation,
|
|
||||||
)
|
|
||||||
// 首次进入时 applyRoute 可能早于项目 watcher 注册。
|
// 首次进入时 applyRoute 可能早于项目 watcher 注册。
|
||||||
if (form.projectKey) void loadRefs()
|
if (form.projectKey) void loadRefs()
|
||||||
|
|
||||||
@@ -173,41 +147,22 @@ async function triggerRelease() {
|
|||||||
if (submitting.value || disabledReason.value) return
|
if (submitting.value || disabledReason.value) return
|
||||||
submitting.value = true
|
submitting.value = true
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm(
|
const plan =
|
||||||
`将 ${selectedProject.value?.name} 的 ${form.ref} 发布到${selectedEnvironment.value?.label}。`,
|
preparedPlan && Date.parse(preparedPlan.expiresAt) > Date.now()
|
||||||
form.environment === 'production' ? '确认生产发布' : '确认发布',
|
? preparedPlan
|
||||||
{
|
: await devopsApi.prepareOperation({
|
||||||
confirmButtonText: '确认发布',
|
kind: 'deploy',
|
||||||
cancelButtonText: '取消',
|
projectKey: form.projectKey,
|
||||||
type: 'warning',
|
environment: form.environment,
|
||||||
autofocus: false,
|
ref: form.ref,
|
||||||
},
|
})
|
||||||
)
|
preparedPlan = plan
|
||||||
} catch {
|
if (!(await confirmOperation(plan))) return
|
||||||
submitting.value = false
|
const run = await platform.executeOperation(plan.confirmationToken!)
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
// 网络重试沿用同一幂等键,参数变更后才开启新的发布请求。
|
|
||||||
requestKey ||= crypto.randomUUID()
|
|
||||||
const run = await platform.createDeployRun({
|
|
||||||
projectKey: form.projectKey,
|
|
||||||
environment: form.environment,
|
|
||||||
ref: form.ref,
|
|
||||||
remark: form.note.trim(),
|
|
||||||
idempotencyKey: requestKey,
|
|
||||||
productionConfirmation:
|
|
||||||
form.environment === 'production'
|
|
||||||
? {
|
|
||||||
confirmed: true,
|
|
||||||
confirmedAt: new Date().toISOString(),
|
|
||||||
summary: `回滚方案:${confirmation.rollback.trim()};业务窗口:${confirmation.window.trim()};通知对象:${confirmation.notify.trim()}`,
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
})
|
|
||||||
submittedRunId.value = run.id
|
submittedRunId.value = run.id
|
||||||
requestKey = ''
|
preparedPlan = undefined
|
||||||
ElMessage.success('发布已提交,可查看进度与日志')
|
if (run.status === 'failed') ElMessage.error('发布未成功,请查看日志')
|
||||||
|
else ElMessage.success('发布已提交,可查看实际进度与日志')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(error instanceof Error ? error.message : '发布提交失败,请重试')
|
ElMessage.error(error instanceof Error ? error.message : '发布提交失败,请重试')
|
||||||
} finally {
|
} finally {
|
||||||
@@ -243,7 +198,6 @@ async function triggerRelease() {
|
|||||||
<section class="panel release-form">
|
<section class="panel release-form">
|
||||||
<div class="panel-header">
|
<div class="panel-header">
|
||||||
<h2>发布内容</h2>
|
<h2>发布内容</h2>
|
||||||
<span>01 — 选择目标</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<ElForm label-position="top" @submit.prevent="triggerRelease">
|
<ElForm label-position="top" @submit.prevent="triggerRelease">
|
||||||
@@ -292,7 +246,9 @@ async function triggerRelease() {
|
|||||||
@click="loadRefs"
|
@click="loadRefs"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="refsError" class="inline-error" role="alert">{{ refsError }}</div>
|
<div v-if="refsError" class="inline-error" role="alert">
|
||||||
|
{{ refsError }}
|
||||||
|
</div>
|
||||||
<div v-if="sha" class="commit-preview">
|
<div v-if="sha" class="commit-preview">
|
||||||
<span class="mono">{{ sha.slice(0, 10) }}</span
|
<span class="mono">{{ sha.slice(0, 10) }}</span
|
||||||
><span>{{ selectedRef?.commit?.message?.split('\n')[0] || '无提交说明' }}</span>
|
><span>{{ selectedRef?.commit?.message?.split('\n')[0] || '无提交说明' }}</span>
|
||||||
@@ -309,43 +265,11 @@ async function triggerRelease() {
|
|||||||
当前为后端备用版本列表,请确认仓库接入后再发布。
|
当前为后端备用版本列表,请确认仓库接入后再发布。
|
||||||
</div>
|
</div>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
<ElFormItem label="发布备注(选填)"
|
|
||||||
><ElInput
|
|
||||||
v-model="form.note"
|
|
||||||
type="textarea"
|
|
||||||
:rows="2"
|
|
||||||
maxlength="120"
|
|
||||||
show-word-limit
|
|
||||||
placeholder="这次发布改了什么…"
|
|
||||||
aria-label="发布备注"
|
|
||||||
/></ElFormItem>
|
|
||||||
<section v-if="form.environment === 'production'" class="production-confirmation">
|
<section v-if="form.environment === 'production'" class="production-confirmation">
|
||||||
<h2>生产发布确认</h2>
|
<h2>生产发布确认</h2>
|
||||||
<p>核对目标版本,并说明发布与回滚安排。</p>
|
<p>将部署所选版本,提交前还会显示锁定的具体提交。</p>
|
||||||
<ElFormItem label="回滚方案"
|
|
||||||
><ElInput
|
|
||||||
v-model="confirmation.rollback"
|
|
||||||
maxlength="90"
|
|
||||||
placeholder="例如:回滚到上一个生产标签…"
|
|
||||||
aria-label="回滚方案"
|
|
||||||
/></ElFormItem>
|
|
||||||
<div class="confirmation-grid">
|
|
||||||
<ElFormItem label="发布窗口"
|
|
||||||
><ElInput
|
|
||||||
v-model="confirmation.window"
|
|
||||||
maxlength="60"
|
|
||||||
placeholder="例如:今晚 23:00…"
|
|
||||||
aria-label="发布窗口" /></ElFormItem
|
|
||||||
><ElFormItem label="通知对象"
|
|
||||||
><ElInput
|
|
||||||
v-model="confirmation.notify"
|
|
||||||
maxlength="80"
|
|
||||||
placeholder="例如:项目负责人…"
|
|
||||||
aria-label="通知对象"
|
|
||||||
/></ElFormItem>
|
|
||||||
</div>
|
|
||||||
<ElCheckbox v-model="confirmation.reviewed"
|
<ElCheckbox v-model="confirmation.reviewed"
|
||||||
>已核对版本、构建任务和以上生产发布安排</ElCheckbox
|
>已核对目标版本,确认发布到生产环境</ElCheckbox
|
||||||
>
|
>
|
||||||
</section>
|
</section>
|
||||||
<div class="submit-row">
|
<div class="submit-row">
|
||||||
@@ -368,7 +292,9 @@ async function triggerRelease() {
|
|||||||
<div class="panel-header"><h2>目标环境</h2></div>
|
<div class="panel-header"><h2>目标环境</h2></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<strong class="context-project">{{ selectedProject?.name || '尚未选择项目' }}</strong>
|
<strong class="context-project">{{ selectedProject?.name || '尚未选择项目' }}</strong>
|
||||||
<p class="context-environment">{{ selectedEnvironment?.label || '—' }}</p>
|
<p class="context-environment">
|
||||||
|
{{ selectedEnvironment?.label || '—' }}
|
||||||
|
</p>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>最近发布</dt>
|
<dt>最近发布</dt>
|
||||||
<dd v-if="latestRun"><StatusPill :state="latestRun.status" /></dd>
|
<dd v-if="latestRun"><StatusPill :state="latestRun.status" /></dd>
|
||||||
@@ -386,13 +312,6 @@ async function triggerRelease() {
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<details class="checks" open>
|
|
||||||
<summary>发布检查</summary>
|
|
||||||
<div v-for="check in checks" :key="check.title" class="check-row">
|
|
||||||
<span>{{ check.title }}</span
|
|
||||||
><StatusPill :state="check.state" :text="check.text" />
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+50
-42
@@ -1,4 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { devopsApi } from '../services/devopsApi'
|
||||||
|
import { confirmOperation } from '../services/operationConfirmation'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
@@ -34,7 +36,9 @@ function filter(key: string) {
|
|||||||
return computed({
|
return computed({
|
||||||
get: () => query(key),
|
get: () => query(key),
|
||||||
set: (value: string) => {
|
set: (value: string) => {
|
||||||
void router.replace({ query: { ...route.query, [key]: value || undefined, page: undefined } })
|
void router.replace({
|
||||||
|
query: { ...route.query, [key]: value || undefined, page: undefined },
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -84,7 +88,9 @@ function resetFilters() {
|
|||||||
void router.replace({ query: { runId: route.query.runId } })
|
void router.replace({ query: { runId: route.query.runId } })
|
||||||
}
|
}
|
||||||
function changePage(value: number) {
|
function changePage(value: number) {
|
||||||
void router.replace({ query: { ...route.query, page: value > 1 ? value : undefined } })
|
void router.replace({
|
||||||
|
query: { ...route.query, page: value > 1 ? value : undefined },
|
||||||
|
})
|
||||||
}
|
}
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
busy.value = 'refresh'
|
busy.value = 'refresh'
|
||||||
@@ -96,48 +102,33 @@ async function refresh() {
|
|||||||
busy.value = ''
|
busy.value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function runAction(action: 'retry' | 'cancel' | 'sync') {
|
async function runAction(action: 'retry' | 'cancel' | 'sync' | 'rollback') {
|
||||||
const run = selectedRun.value
|
const run = selectedRun.value
|
||||||
if (!run || !platform.canBuildProject(run.projectKey) || busy.value) return
|
if (!run || !platform.canBuildProject(run.projectKey) || busy.value) return
|
||||||
const label = { retry: '重试发布', cancel: '取消发布', sync: '同步构建状态' }[action]
|
|
||||||
busy.value = action
|
busy.value = action
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm(
|
if (action === 'sync') {
|
||||||
`${label}:${run.projectName} / ${run.environment === 'production' ? '生产' : '测试'} / ${run.ref}`,
|
await platform.syncJenkinsRun(run)
|
||||||
label,
|
ElMessage.success('已读取最新构建状态')
|
||||||
{
|
return
|
||||||
confirmButtonText: `确认${label}`,
|
}
|
||||||
cancelButtonText: '返回',
|
const plan = await devopsApi.prepareOperation({
|
||||||
type: 'warning',
|
kind: action,
|
||||||
autofocus: false,
|
runId: run.id,
|
||||||
},
|
})
|
||||||
)
|
if (!(await confirmOperation(plan))) return
|
||||||
} catch {
|
const result = await platform.executeOperation(plan.confirmationToken!)
|
||||||
busy.value = ''
|
selectRun(result)
|
||||||
return
|
if (result.status === 'failed') ElMessage.error('操作未成功,请查看日志')
|
||||||
}
|
else ElMessage.success('操作已提交,可查看实际进度与日志')
|
||||||
try {
|
|
||||||
const result =
|
|
||||||
action === 'retry'
|
|
||||||
? await platform.retryDeployRun(run)
|
|
||||||
: action === 'cancel'
|
|
||||||
? await platform.cancelDeployRun(run)
|
|
||||||
: await platform.syncJenkinsRun(run)
|
|
||||||
if (action === 'retry') selectRun(result)
|
|
||||||
ElMessage.success(`${label}已完成`)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isDevopsApiError(error) && error.code === 'CONFLICT') {
|
if (isDevopsApiError(error) && error.code === 'CONFLICT') await refresh()
|
||||||
try {
|
ElMessage.error(error instanceof Error ? error.message : '操作失败,请重试')
|
||||||
await platform.refreshRuns()
|
|
||||||
ElMessage.warning('发布状态已变化,已刷新最新记录')
|
|
||||||
} catch {
|
|
||||||
ElMessage.error('状态已变化,刷新失败,请重试')
|
|
||||||
}
|
|
||||||
} else ElMessage.error(error instanceof Error ? error.message : `${label}失败`)
|
|
||||||
} finally {
|
} finally {
|
||||||
busy.value = ''
|
busy.value = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function adminAction(action: string | number | object) {
|
async function adminAction(action: string | number | object) {
|
||||||
if (session.role !== 'super_admin' || busy.value || (action !== 'import' && action !== 'sync'))
|
if (session.role !== 'super_admin' || busy.value || (action !== 'import' && action !== 'sync'))
|
||||||
return
|
return
|
||||||
@@ -207,7 +198,9 @@ async function adminAction(action: string | number | object) {
|
|||||||
:title="toolResult"
|
:title="toolResult"
|
||||||
:type="toolFailures.length ? 'warning' : 'success'"
|
:type="toolFailures.length ? 'warning' : 'success'"
|
||||||
@close="toolResult = ''"
|
@close="toolResult = ''"
|
||||||
><p v-for="failure in toolFailures" :key="failure">{{ failure }}</p></ElAlert
|
><p v-for="failure in toolFailures" :key="failure">
|
||||||
|
{{ failure }}
|
||||||
|
</p></ElAlert
|
||||||
>
|
>
|
||||||
<section class="panel">
|
<section class="panel">
|
||||||
<div class="run-filters">
|
<div class="run-filters">
|
||||||
@@ -248,7 +241,9 @@ async function adminAction(action: string | number | object) {
|
|||||||
>
|
>
|
||||||
<ElTableColumn label="项目 / 版本" min-width="210"
|
<ElTableColumn label="项目 / 版本" min-width="210"
|
||||||
><template #default="{ row }"
|
><template #default="{ row }"
|
||||||
><button class="run-name" @click.stop="selectRun(row)">{{ row.projectName }}</button>
|
><button class="run-name" @click.stop="selectRun(row)">
|
||||||
|
{{ row.projectName }}
|
||||||
|
</button>
|
||||||
<div class="field-hint mono">{{ row.ref }}</div></template
|
<div class="field-hint mono">{{ row.ref }}</div></template
|
||||||
></ElTableColumn
|
></ElTableColumn
|
||||||
>
|
>
|
||||||
@@ -315,10 +310,7 @@ async function adminAction(action: string | number | object) {
|
|||||||
>Jenkins #{{ selectedRun.jenkinsBuildNumber }} ↗</a
|
>Jenkins #{{ selectedRun.jenkinsBuildNumber }} ↗</a
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div v-if="canAct" class="run-actions toolbar">
|
||||||
v-if="canAct && (selectedActive || ['failed', 'canceled'].includes(selectedRun.status))"
|
|
||||||
class="run-actions toolbar"
|
|
||||||
>
|
|
||||||
<ElButton
|
<ElButton
|
||||||
v-if="selectedActive && (selectedRun.jenkinsQueueId || selectedRun.jenkinsBuildNumber)"
|
v-if="selectedActive && (selectedRun.jenkinsQueueId || selectedRun.jenkinsBuildNumber)"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -341,7 +333,21 @@ async function adminAction(action: string | number | object) {
|
|||||||
@click="runAction('retry')"
|
@click="runAction('retry')"
|
||||||
>重试发布</ElButton
|
>重试发布</ElButton
|
||||||
>
|
>
|
||||||
|
<ElButton
|
||||||
|
v-if="selectedRun.status === 'success'"
|
||||||
|
size="small"
|
||||||
|
:loading="busy === 'rollback'"
|
||||||
|
:disabled="Boolean(busy)"
|
||||||
|
@click="runAction('rollback')"
|
||||||
|
>回滚到此版本</ElButton
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
|
<p v-if="selectedRun.resolvedCommit" class="field-hint">
|
||||||
|
{{ selectedRun.operationKind === 'rollback' ? '回滚提交' : '实际锁定提交' }}:<span
|
||||||
|
class="mono"
|
||||||
|
>{{ selectedRun.resolvedCommit }}</span
|
||||||
|
>
|
||||||
|
</p>
|
||||||
<ElButton
|
<ElButton
|
||||||
class="ask-run"
|
class="ask-run"
|
||||||
text
|
text
|
||||||
@@ -388,7 +394,9 @@ async function adminAction(action: string | number | object) {
|
|||||||
|
|
||||||
.run-filters {
|
.run-filters {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: minmax(150px, 1.2fr) 115px 120px minmax(200px, 1.4fr) auto;
|
grid-template-columns:
|
||||||
|
minmax(150px, 1.2fr) 115px 120px minmax(200px, 1.4fr)
|
||||||
|
auto;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ function variableHelp(item: IntegrationConfigItem, name: string) {
|
|||||||
function variableDescription(
|
function variableDescription(
|
||||||
item: IntegrationConfigItem,
|
item: IntegrationConfigItem,
|
||||||
name: string,
|
name: string,
|
||||||
group: VariableGroup,
|
_group: VariableGroup,
|
||||||
): string {
|
): string {
|
||||||
const help = variableHelp(item, name)
|
const help = variableHelp(item, name)
|
||||||
|
|
||||||
@@ -343,12 +343,9 @@ function variableDescription(
|
|||||||
return item.note
|
return item.note
|
||||||
}
|
}
|
||||||
|
|
||||||
return `后端暂未返回 ${item.name} ${group.label} ${name} 的变量说明;请在 /settings/integration-config 响应中补充 variableHelp。`
|
return '该变量由服务端配置。'
|
||||||
}
|
}
|
||||||
|
|
||||||
function variableSourceLabel(item: IntegrationConfigItem, name: string): string {
|
|
||||||
return variableHelp(item, name)?.description ? '后端返回' : '等待后端说明'
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadAgentConfig() {
|
async function loadAgentConfig() {
|
||||||
if (!canManageSystemConfig.value) {
|
if (!canManageSystemConfig.value) {
|
||||||
@@ -552,7 +549,6 @@ function resetAuditFilters() {
|
|||||||
<div class="variable-tooltip">
|
<div class="variable-tooltip">
|
||||||
<strong class="mono">{{ name }}</strong>
|
<strong class="mono">{{ name }}</strong>
|
||||||
<p>{{ variableDescription(item, name, group) }}</p>
|
<p>{{ variableDescription(item, name, group) }}</p>
|
||||||
<small>{{ group.label }} · {{ variableSourceLabel(item, name) }}</small>
|
|
||||||
<small v-if="variableHelp(item, name)?.example">
|
<small v-if="variableHelp(item, name)?.example">
|
||||||
示例:{{ variableHelp(item, name)?.example }}
|
示例:{{ variableHelp(item, name)?.example }}
|
||||||
</small>
|
</small>
|
||||||
|
|||||||
@@ -232,3 +232,27 @@ test('退出时清空助手,迟到的回答不能回填新会话', async () =>
|
|||||||
assert.equal(assistant.pending, false)
|
assert.equal(assistant.pending, false)
|
||||||
assert.equal(assistant.isOpen, false)
|
assert.equal(assistant.isOpen, false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('确认操作使用后端回执更新记录,退出后的迟到结果不能回填', async () => {
|
||||||
|
const store = usePlatformStore()
|
||||||
|
const pending = deferred()
|
||||||
|
devopsApi.executeOperation = () => pending.promise
|
||||||
|
const request = store.executeOperation('signed-plan')
|
||||||
|
store.reset()
|
||||||
|
pending.resolve(run('new-operation', '2026-10-28', 'queued'))
|
||||||
|
await request
|
||||||
|
assert.equal(store.runs.length, 0)
|
||||||
|
devopsApi.executeOperation = async () => run('accepted-operation', '2026-10-28', 'queued')
|
||||||
|
const receipt = await store.executeOperation('signed-plan')
|
||||||
|
assert.equal(receipt.id, 'accepted-operation')
|
||||||
|
assert.equal(store.runs[0].id, receipt.id)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('助手保留服务端操作卡片,清空会话后不残留执行计划', async () => {
|
||||||
|
const store = useAssistantStore()
|
||||||
|
devopsApi.askAgent = async () => ({id:'answer',status:'success',resultMarkdown:'等待确认',operationPlans:[{id:'plan',kind:'deploy',projectKey:'app',environment:'test',ref:'develop',confirmationToken:'signed-plan'}]})
|
||||||
|
await store.ask('部署 app 测试环境')
|
||||||
|
assert.equal(store.messages.at(-1).operationPlans[0].confirmationToken,'signed-plan')
|
||||||
|
store.reset()
|
||||||
|
assert.equal(store.messages.length,0)
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user