Skip to content

Commit

Permalink
Fix streaming logs output from a PipelineRun on start
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhirverma committed Jul 7, 2021
1 parent 8f0fb8e commit 2ad3ed5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
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 PipelineRun Follow Logs` - Show pipelineRun follow logs while starting pipeline.

### Dependencies

Expand Down
6 changes: 6 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.showPipelineRunFollowLogs": {
"title": "Show pipelineRun follow Logs",
"type": "boolean",
"default": true,
"description": "Show pipelineRun follow logs while starting pipeline."
},
"vs-tekton.outputVerbosityLevel": {
"title": "Output Verbosity Level",
"type": "number",
Expand Down
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('showPipelineRunFollowLogs')) 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

0 comments on commit 2ad3ed5

Please sign in to comment.