added setupoptions for github
This commit is contained in:
@@ -3,10 +3,11 @@ import { injectable } from "inversify";
|
||||
import * as taskLib from "azure-pipelines-task-lib/task";
|
||||
import * as toolLib from "azure-pipelines-tool-lib/tool";
|
||||
|
||||
import { IBuildAgent, IExecResult } from "../interfaces";
|
||||
import { IBuildAgent, IExecResult } from "../interface";
|
||||
|
||||
@injectable()
|
||||
class BuildAgent implements IBuildAgent {
|
||||
|
||||
public find(toolName: string, versionSpec: string, arch?: string): string {
|
||||
return toolLib.findLocalTool(toolName, versionSpec, arch);
|
||||
}
|
||||
@@ -35,6 +36,10 @@ class BuildAgent implements IBuildAgent {
|
||||
taskLib.setVariable(name, val);
|
||||
}
|
||||
|
||||
public getVariable(name: string): string {
|
||||
return taskLib.getVariable(name);
|
||||
}
|
||||
|
||||
public addPath(inputPath: string): void {
|
||||
toolLib.prependPath(inputPath);
|
||||
}
|
||||
@@ -55,6 +60,14 @@ class BuildAgent implements IBuildAgent {
|
||||
stdout: result.stdout,
|
||||
});
|
||||
}
|
||||
|
||||
public getInput(input: string, required?: boolean): string {
|
||||
return taskLib.getInput(input, required);
|
||||
}
|
||||
|
||||
public getBooleanInput(input: string, required?: boolean): boolean {
|
||||
return taskLib.getBoolInput(input, required);
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { IBuildAgent, IGitVersionTool } from "../interfaces";
|
||||
import { IBuildAgent, IGitVersionTool } from "../interface";
|
||||
import { TYPES } from "../types";
|
||||
import { ioc } from "./ioc";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Container } from "inversify";
|
||||
|
||||
import { DotnetTool, GitVersionTool, VersionManager } from "../common";
|
||||
import { IBuildAgent, IDotnetTool, IGitVersionTool, IVersionManager } from "../interfaces";
|
||||
import { IBuildAgent, IDotnetTool, IGitVersionTool, IVersionManager } from "../interface";
|
||||
import { TYPES } from "../types";
|
||||
import { BuildAgent } from "./build-agent";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { IBuildAgent, IGitVersionTool } from "../interfaces";
|
||||
import { IBuildAgent, IGitVersionTool } from "../interface";
|
||||
import { TYPES } from "../types";
|
||||
import { ioc } from "./ioc";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as http from "typed-rest-client/HttpClient";
|
||||
|
||||
import { inject, injectable } from "inversify";
|
||||
|
||||
import { Argument, IBuildAgent, IDotnetTool, IExecResult, IGitVersionTool, IVersionManager } from "./interfaces";
|
||||
import { Argument, IBuildAgent, IDotnetTool, IExecResult, IGitVersionTool, IVersionManager } from "./interface";
|
||||
import { TYPES } from "./types";
|
||||
|
||||
@injectable()
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as toolCache from "@actions/tool-cache";
|
||||
|
||||
import { injectable } from "inversify";
|
||||
|
||||
import { IBuildAgent, IExecResult } from "../interfaces";
|
||||
import { IBuildAgent, IExecResult } from "../interface";
|
||||
|
||||
@injectable()
|
||||
class BuildAgent implements IBuildAgent {
|
||||
@@ -61,6 +61,10 @@ class BuildAgent implements IBuildAgent {
|
||||
core.exportVariable(name, val);
|
||||
}
|
||||
|
||||
public getVariable(name: string): string {
|
||||
return process.env[name];
|
||||
}
|
||||
|
||||
public addPath(inputPath: string): void {
|
||||
core.addPath(inputPath);
|
||||
}
|
||||
@@ -94,6 +98,15 @@ class BuildAgent implements IBuildAgent {
|
||||
stdout,
|
||||
};
|
||||
}
|
||||
|
||||
public getInput(input: string, required?: boolean): string {
|
||||
return core.getInput(input, { required } as core.InputOptions);
|
||||
}
|
||||
|
||||
public getBooleanInput(input: string, required?: boolean): boolean {
|
||||
const inputValue = this.getInput(input, required);
|
||||
return (inputValue || "false").toLowerCase() === "true";
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { IBuildAgent, IGitVersionTool } from "../interfaces";
|
||||
import { IBuildAgent, IGitVersionTool } from "../interface";
|
||||
import { TYPES } from "../types";
|
||||
import { ioc } from "./ioc";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Container } from "inversify";
|
||||
|
||||
import { DotnetTool, GitVersionTool, VersionManager } from "../common";
|
||||
import { IBuildAgent, IDotnetTool, IGitVersionTool, IVersionManager } from "../interfaces";
|
||||
import { IBuildAgent, IDotnetTool, IGitVersionTool, IVersionManager } from "../interface";
|
||||
import { TYPES } from "../types";
|
||||
import { BuildAgent } from "./build-agent";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { IBuildAgent, IGitVersionTool } from "../interfaces";
|
||||
import { TYPES } from "../types";
|
||||
import { IBuildAgent, IGitVersionTool } from "../interface";
|
||||
import { SetupOptions, TYPES } from "../types";
|
||||
import { ioc } from "./ioc";
|
||||
|
||||
const gitVersionTool = ioc.get<IGitVersionTool>(TYPES.IGitVersionTool);
|
||||
@@ -10,11 +10,12 @@ const buildAgent = ioc.get<IBuildAgent>(TYPES.IBuildAgent);
|
||||
export async function run() {
|
||||
try {
|
||||
|
||||
const version = "5.1.2";
|
||||
const includePrerelease = false;
|
||||
|
||||
buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
||||
await gitVersionTool.install(version, includePrerelease);
|
||||
|
||||
const versionSpec = this.buildAgent.getInput(SetupOptions.versionSpec);
|
||||
const includePrerelease = this.buildAgent.getBooleanInput(SetupOptions.includePrerelease);
|
||||
|
||||
await gitVersionTool.install(versionSpec, includePrerelease);
|
||||
|
||||
buildAgent.setSucceeded("GitVersion installed successfully", true);
|
||||
} catch (error) {
|
||||
|
||||
@@ -12,9 +12,13 @@ export interface IBuildAgent {
|
||||
setFailed: (message: string, done?: boolean) => void;
|
||||
setSucceeded: (message: string, done?: boolean) => void;
|
||||
exportVariable: (name: string, val: string) => void;
|
||||
getVariable: (name: string) => string;
|
||||
addPath: (inputPath: string) => void;
|
||||
which: (tool: string, check?: boolean) => Promise<string>;
|
||||
exec: (exec: string, args: string[]) => Promise<IExecResult>;
|
||||
|
||||
getInput(input: string, required?: boolean): string;
|
||||
getBooleanInput(input: string, required?: boolean): boolean;
|
||||
}
|
||||
|
||||
export interface IDotnetTool {
|
||||
@@ -5,4 +5,9 @@ const TYPES = {
|
||||
IVersionManager: Symbol.for("VersionManager"),
|
||||
};
|
||||
|
||||
export { TYPES };
|
||||
const SetupOptions = {
|
||||
includePrerelease: "includePrerelease",
|
||||
versionSpec: "versionSpec",
|
||||
};
|
||||
|
||||
export { SetupOptions, TYPES };
|
||||
|
||||
Reference in New Issue
Block a user