Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix streaming logs output from a PipelineRun on start #606

Merged
merged 3 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ Development of the Tekton Pipelines Extension is largely following development o


### Extension Configuration Settings
* `Tekton Pipelines: Show Channel On Output` - Show Tekton Pipelines output channel when new text added to output stream
* `Tekton Pipelines: Show Channel On Output` - Show Tekton Pipelines output channel when new text added to output stream.
* `Tekton Pipelines: Output verbosity level` - Output verbosity level (value between 0 and 9) for Tekton Pipeline Start, Push and Watch commands in output channel and integrated terminal.
* `Tekton Pipelines: Show reference resource notification` - Enable/disable to check Task and ClusterTask Reference Resource.
* `Tekton Pipelines: Show logs on pipeline start` - Show pipelineRun follow logs while starting pipeline.

### Dependencies

Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
"default": false,
"description": "Show Tekton Pipeline output channel when new text added to output stream"
},
"vs-tekton.showLogsOnPipelineStart": {
"title": "Start pipeline with logs",
"type": "boolean",
"default": true,
"description": "Show PipelineRun follow logs while starting pipeline."
},
"vs-tekton.outputVerbosityLevel": {
"title": "Output Verbosity Level",
"type": "number",
Expand Down Expand Up @@ -980,3 +986,4 @@
"vscode-kubernetes-tools-api": "1.3.0"
}
}

10 changes: 10 additions & 0 deletions src/tekton/addtrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { getStderrString } from '../util/stderrstring';
import { Command } from '../cli-command';
import semver = require('semver');
import { ClusterTaskModel, EventListenerModel, PipelineRunModel, TaskModel, TriggerTemplateModel } from '../util/resource-kind';
import { showPipelineRunPreview } from '../pipeline/pipeline-preview';
import { PipelineRun } from './pipelinerun';

export enum WorkspaceResource {
Secret = 'secret',
Expand Down Expand Up @@ -96,6 +98,14 @@ export async function k8sCreate(trigger: TriggerTemplateKind | EventListenerKind
if (kind === PipelineRunModel.kind && !result.error) {
const message = 'Pipeline successfully started';
telemetryLog(commandId, message);
if (TektonItem.ShowPipelineRun()) {
const pipelineRunNameRegex = new RegExp(`${trigger.metadata.generateName}\\w*`);
const pipelineRunName = result.stdout.match(pipelineRunNameRegex)[0];
if (pipelineRunName) {
await showPipelineRunPreview(pipelineRunName);
if (vscode.workspace.getConfiguration('vs-tekton').get('showLogsOnPipelineStart')) PipelineRun.pipelineRunFollowLogs(pipelineRunName);
}
}
vscode.window.showInformationMessage(message);
}
if ((kind === TaskModel.kind || kind === ClusterTaskModel.kind) && !result.error) {
Expand Down
8 changes: 6 additions & 2 deletions src/tekton/pipelinerun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ export class PipelineRun extends TektonItem {
if (!pipelineRun){
return;
}
this.pipelineRunFollowLogs(pipelineRun.getName());
}

static async pipelineRunFollowLogs(pipelineRunName: string): Promise<void> {
if (workspace.getConfiguration('vs-tekton').get('showLogInEditor')) {
showLogInEditor(Command.showPipelineRunFollowLogs(pipelineRun.getName()), `Log: ${pipelineRun.getName()}`);
showLogInEditor(Command.showPipelineRunFollowLogs(pipelineRunName), `Log: ${pipelineRunName}`);
} else {
PipelineRun.tkn.executeInTerminal(Command.showPipelineRunFollowLogs(pipelineRun.getName()));
PipelineRun.tkn.executeInTerminal(Command.showPipelineRunFollowLogs(pipelineRunName));
}
}

Expand Down