mirror of
https://github.com/certd/certd.git
synced 2026-04-14 12:30:54 +08:00
fix: 修复首次创建任务运行时不自动设置当前运行情况的bug
This commit is contained in:
@@ -186,10 +186,15 @@ h1, h2, h3, h4, h5, h6 {
|
||||
}
|
||||
|
||||
|
||||
.disabled{
|
||||
color: #c7c7c7;
|
||||
}
|
||||
.deleted{
|
||||
color: #c7c7c7;
|
||||
//删除线
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.cursor-move{
|
||||
cursor: move !important;
|
||||
}
|
||||
.cursor-pointer{
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -51,11 +51,11 @@
|
||||
<h4 class="title" :class="{ disabled: element.disabled, deleted: element.disabled }">{{ element.title }}</h4>
|
||||
</div>
|
||||
<div class="action">
|
||||
<a key="disabled" @click="element.disabled = !!!element.disabled">{{ element.disabled ? "启用" : "禁用" }}</a>
|
||||
<a key="edit" @click="stepEdit(currentTask, element, index)">编辑</a>
|
||||
<a key="edit" @click="stepCopy(currentTask, element, index)">复制</a>
|
||||
<a key="remove" @click="stepDelete(currentTask, index)">删除</a>
|
||||
<fs-icon v-plus class="icon-button handle" title="拖动排序" icon="ion:move-outline"></fs-icon>
|
||||
<a key="disabled" @click="element.disabled = !!!element.disabled">{{ element.disabled ? "启用" : "禁用" }}</a>
|
||||
<fs-icon v-plus class="icon-button handle cursor-move" title="拖动排序" icon="ion:move-outline"></fs-icon>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -354,7 +354,7 @@ export default defineComponent({
|
||||
await loadHistoryList();
|
||||
}
|
||||
|
||||
if (!currentHistory.value) {
|
||||
if (currentHistory.value != null) {
|
||||
if (currentHistory.value.pipeline?.status?.status === "start") {
|
||||
await loadCurrentHistoryDetail();
|
||||
} else {
|
||||
@@ -614,6 +614,9 @@ export default defineComponent({
|
||||
saveLoading.value = true;
|
||||
try {
|
||||
if (props.options.doSave) {
|
||||
if (pipeline.value.version == null) {
|
||||
pipeline.value.version = 0;
|
||||
}
|
||||
pipeline.value.version++;
|
||||
currentPipeline.value = pipeline.value;
|
||||
await props.options.doSave(pipeline.value);
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from './plugin-k8s.js';
|
||||
export * from './plugin-script.js';
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskInstanceContext } from '@certd/pipeline';
|
||||
import { CertInfo, CertReader } from '@certd/plugin-cert';
|
||||
|
||||
export type CustomScriptContext = {
|
||||
CertReader: typeof CertReader;
|
||||
self: CustomScriptPlugin;
|
||||
} & TaskInstanceContext;
|
||||
|
||||
@IsTaskPlugin({
|
||||
name: 'CustomScript',
|
||||
title: '自定义js脚本',
|
||||
desc: '测试',
|
||||
group: pluginGroups.other.key,
|
||||
default: {
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
},
|
||||
},
|
||||
})
|
||||
export class CustomScriptPlugin extends AbstractTaskPlugin {
|
||||
@TaskInput({
|
||||
title: '脚本',
|
||||
helper: '自定义js脚本',
|
||||
component: {
|
||||
name: 'a-textarea',
|
||||
vModel: 'value',
|
||||
rows: 10,
|
||||
style: 'background-color: #000c17;color: #fafafa;',
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
script!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: '域名证书',
|
||||
helper: '请选择前置任务输出的域名证书',
|
||||
component: {
|
||||
name: 'pi-output-selector',
|
||||
from: 'CertApply',
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
cert!: CertInfo;
|
||||
|
||||
async onInstance() {}
|
||||
async execute(): Promise<void> {
|
||||
this.logger.info('执行自定义脚本:\n', this.script);
|
||||
const ctx: CustomScriptContext = {
|
||||
CertReader,
|
||||
self: this,
|
||||
...this.ctx,
|
||||
};
|
||||
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
|
||||
const func = new AsyncFunction('ctx', this.script);
|
||||
return await func(ctx);
|
||||
}
|
||||
}
|
||||
new CustomScriptPlugin();
|
||||
Reference in New Issue
Block a user