added prettier tool
This commit is contained in:
@@ -1,106 +1,108 @@
|
||||
import { injectable } from "inversify";
|
||||
import {injectable} from 'inversify'
|
||||
|
||||
import * as taskLib from "azure-pipelines-task-lib/task";
|
||||
import * as toolLib from "azure-pipelines-tool-lib/tool";
|
||||
import * as taskLib from 'azure-pipelines-task-lib/task'
|
||||
import * as toolLib from 'azure-pipelines-tool-lib/tool'
|
||||
|
||||
import { IBuildAgent, IExecResult } from "../../core/models";
|
||||
import {IBuildAgent, IExecResult} from '../../core/models'
|
||||
|
||||
@injectable()
|
||||
class BuildAgent implements IBuildAgent {
|
||||
|
||||
public get agentName(): string {
|
||||
return "Azure Pipelines";
|
||||
return 'Azure Pipelines'
|
||||
}
|
||||
|
||||
public find(toolName: string, versionSpec: string, arch?: string): string {
|
||||
return toolLib.findLocalTool(toolName, versionSpec, arch);
|
||||
return toolLib.findLocalTool(toolName, versionSpec, arch)
|
||||
}
|
||||
|
||||
public cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string> {
|
||||
return toolLib.cacheDir(sourceDir, tool, version, arch);
|
||||
public cacheDir(
|
||||
sourceDir: string,
|
||||
tool: string,
|
||||
version: string,
|
||||
arch?: string
|
||||
): Promise<string> {
|
||||
return toolLib.cacheDir(sourceDir, tool, version, arch)
|
||||
}
|
||||
|
||||
public createTempDir(): Promise<string> {
|
||||
return Promise.resolve(taskLib.getVariable("Agent.TempDirectory"));
|
||||
return Promise.resolve(taskLib.getVariable('Agent.TempDirectory'))
|
||||
}
|
||||
|
||||
public debug(message: string): void {
|
||||
taskLib.debug(message);
|
||||
taskLib.debug(message)
|
||||
}
|
||||
|
||||
public setFailed(message: string, done?: boolean): void {
|
||||
taskLib.setResult(taskLib.TaskResult.Failed, message, done);
|
||||
taskLib.setResult(taskLib.TaskResult.Failed, message, done)
|
||||
}
|
||||
|
||||
public setSucceeded(message: string, done?: boolean): void {
|
||||
taskLib.setResult(taskLib.TaskResult.Succeeded, message, done);
|
||||
taskLib.setResult(taskLib.TaskResult.Succeeded, message, done)
|
||||
}
|
||||
|
||||
public exportVariable(name: string, val: string): void {
|
||||
taskLib.setVariable(name, val);
|
||||
taskLib.setVariable(name, val)
|
||||
}
|
||||
|
||||
public getVariable(name: string): string {
|
||||
return taskLib.getVariable(name);
|
||||
return taskLib.getVariable(name)
|
||||
}
|
||||
|
||||
public addPath(inputPath: string): void {
|
||||
toolLib.prependPath(inputPath);
|
||||
toolLib.prependPath(inputPath)
|
||||
}
|
||||
|
||||
public which(tool: string, check?: boolean): Promise<string> {
|
||||
return Promise.resolve(taskLib.which(tool, check));
|
||||
return Promise.resolve(taskLib.which(tool, check))
|
||||
}
|
||||
|
||||
public exec(exec: string, args: string[]): Promise<IExecResult> {
|
||||
const tr = taskLib.tool(exec);
|
||||
tr.arg(args);
|
||||
const tr = taskLib.tool(exec)
|
||||
tr.arg(args)
|
||||
|
||||
const result = tr.execSync();
|
||||
const result = tr.execSync()
|
||||
return Promise.resolve({
|
||||
code: result.code,
|
||||
error: result.error,
|
||||
stderr: result.stderr,
|
||||
stdout: result.stdout,
|
||||
});
|
||||
stdout: result.stdout
|
||||
})
|
||||
}
|
||||
|
||||
public getSourceDir(): string {
|
||||
return this.getVariable("Build.SourcesDirectory");
|
||||
return this.getVariable('Build.SourcesDirectory')
|
||||
}
|
||||
|
||||
public setOutput(name: string, value: string): void {
|
||||
taskLib.setVariable(name, value);
|
||||
taskLib.setVariable(name, value)
|
||||
}
|
||||
|
||||
public getInput(input: string, required?: boolean): string {
|
||||
return taskLib.getInput(input, required);
|
||||
return taskLib.getInput(input, required)
|
||||
}
|
||||
|
||||
public getListInput(input: string, required?: boolean): string[] {
|
||||
return taskLib
|
||||
.getInput(input, required)
|
||||
.split("\n")
|
||||
.filter(x => x !== "");
|
||||
.split('\n')
|
||||
.filter(x => x !== '')
|
||||
}
|
||||
|
||||
public getBooleanInput(input: string, required?: boolean): boolean {
|
||||
return taskLib.getBoolInput(input, required);
|
||||
return taskLib.getBoolInput(input, required)
|
||||
}
|
||||
|
||||
public isValidInputFile(input: string, file: string): boolean {
|
||||
return taskLib.filePathSupplied(input) && this.fileExists(file);
|
||||
return taskLib.filePathSupplied(input) && this.fileExists(file)
|
||||
}
|
||||
|
||||
public fileExists(file: string): boolean {
|
||||
return taskLib.exist(file) && taskLib.stats(file).isFile();
|
||||
return taskLib.exist(file) && taskLib.stats(file).isFile()
|
||||
}
|
||||
|
||||
public directoryExists(file: string): boolean {
|
||||
return taskLib.exist(file) && taskLib.stats(file).isDirectory();
|
||||
return taskLib.exist(file) && taskLib.stats(file).isDirectory()
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
BuildAgent,
|
||||
};
|
||||
export {BuildAgent}
|
||||
|
||||
@@ -1,62 +1,66 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
|
||||
import uuidv4 from "uuid";
|
||||
import uuidv4 from 'uuid'
|
||||
|
||||
import * as core from "@actions/core";
|
||||
import * as exe from "@actions/exec";
|
||||
import * as io from "@actions/io";
|
||||
import * as toolCache from "@actions/tool-cache";
|
||||
import * as core from '@actions/core'
|
||||
import * as exe from '@actions/exec'
|
||||
import * as io from '@actions/io'
|
||||
import * as toolCache from '@actions/tool-cache'
|
||||
|
||||
import { injectable } from "inversify";
|
||||
import {injectable} from 'inversify'
|
||||
|
||||
import { IBuildAgent, IExecResult } from "../../core/models";
|
||||
import {IBuildAgent, IExecResult} from '../../core/models'
|
||||
|
||||
@injectable()
|
||||
class BuildAgent implements IBuildAgent {
|
||||
|
||||
public get agentName(): string {
|
||||
return "GitHub Actions";
|
||||
return 'GitHub Actions'
|
||||
}
|
||||
|
||||
public find(toolName: string, versionSpec: string, arch?: string): string {
|
||||
return toolCache.find(toolName, versionSpec, arch);
|
||||
return toolCache.find(toolName, versionSpec, arch)
|
||||
}
|
||||
|
||||
public cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string> {
|
||||
return toolCache.cacheDir(sourceDir, tool, version, arch);
|
||||
public cacheDir(
|
||||
sourceDir: string,
|
||||
tool: string,
|
||||
version: string,
|
||||
arch?: string
|
||||
): Promise<string> {
|
||||
return toolCache.cacheDir(sourceDir, tool, version, arch)
|
||||
}
|
||||
|
||||
public async createTempDir(): Promise<string> {
|
||||
const IS_WINDOWS = process.platform === "win32";
|
||||
const IS_WINDOWS = process.platform === 'win32'
|
||||
|
||||
let tempDirectory: string = process.env.RUNNER_TEMP || "";
|
||||
let tempDirectory: string = process.env.RUNNER_TEMP || ''
|
||||
|
||||
if (!tempDirectory) {
|
||||
let baseLocation: string;
|
||||
let baseLocation: string
|
||||
if (IS_WINDOWS) {
|
||||
// On Windows use the USERPROFILE env variable
|
||||
baseLocation = process.env.USERPROFILE || "C:\\";
|
||||
baseLocation = process.env.USERPROFILE || 'C:\\'
|
||||
} else {
|
||||
if (process.platform === "darwin") {
|
||||
baseLocation = "/Users";
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users'
|
||||
} else {
|
||||
baseLocation = "/home";
|
||||
baseLocation = '/home'
|
||||
}
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, "actions", "temp");
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp')
|
||||
}
|
||||
const dest = path.join(tempDirectory, uuidv4());
|
||||
await io.mkdirP(dest);
|
||||
return dest;
|
||||
const dest = path.join(tempDirectory, uuidv4())
|
||||
await io.mkdirP(dest)
|
||||
return dest
|
||||
}
|
||||
|
||||
public debug(message: string): void {
|
||||
core.debug(message);
|
||||
core.debug(message)
|
||||
}
|
||||
|
||||
public setFailed(message: string, done?: boolean): void {
|
||||
core.setFailed(message);
|
||||
core.setFailed(message)
|
||||
}
|
||||
|
||||
public setSucceeded(message: string, done?: boolean): void {
|
||||
@@ -64,108 +68,103 @@ class BuildAgent implements IBuildAgent {
|
||||
}
|
||||
|
||||
public exportVariable(name: string, val: string): void {
|
||||
core.exportVariable(name, val);
|
||||
core.exportVariable(name, val)
|
||||
}
|
||||
|
||||
public getVariable(name: string): string {
|
||||
return process.env[name];
|
||||
return process.env[name]
|
||||
}
|
||||
|
||||
public addPath(inputPath: string): void {
|
||||
core.addPath(inputPath);
|
||||
core.addPath(inputPath)
|
||||
}
|
||||
|
||||
public which(tool: string, check?: boolean): Promise<string> {
|
||||
return io.which(tool, check);
|
||||
return io.which(tool, check)
|
||||
}
|
||||
|
||||
public async exec(exec: string, args: string[]): Promise<IExecResult> {
|
||||
const dotnetPath = await io.which(exec, true);
|
||||
let resultCode = 0;
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
resultCode = await exe.exec(
|
||||
`"${dotnetPath}"`,
|
||||
args,
|
||||
{
|
||||
listeners: {
|
||||
stderr: (data: Buffer) => {
|
||||
stderr += data.toString();
|
||||
},
|
||||
stdout: (data: Buffer) => {
|
||||
stdout += data.toString();
|
||||
},
|
||||
const dotnetPath = await io.which(exec, true)
|
||||
let resultCode = 0
|
||||
let stdout = ''
|
||||
let stderr = ''
|
||||
resultCode = await exe.exec(`"${dotnetPath}"`, args, {
|
||||
listeners: {
|
||||
stderr: (data: Buffer) => {
|
||||
stderr += data.toString()
|
||||
},
|
||||
});
|
||||
stdout: (data: Buffer) => {
|
||||
stdout += data.toString()
|
||||
}
|
||||
}
|
||||
})
|
||||
return {
|
||||
code: resultCode,
|
||||
error: null,
|
||||
stderr,
|
||||
stdout,
|
||||
};
|
||||
stdout
|
||||
}
|
||||
}
|
||||
|
||||
public getSourceDir(): string {
|
||||
return this.getVariable("GITHUB_WORKSPACE");
|
||||
return this.getVariable('GITHUB_WORKSPACE')
|
||||
}
|
||||
|
||||
public setOutput(name: string, value: string): void {
|
||||
core.setOutput(name, value);
|
||||
core.setOutput(name, value)
|
||||
}
|
||||
|
||||
public getInput(input: string, required?: boolean): string {
|
||||
return core.getInput(input, { required } as core.InputOptions);
|
||||
return core.getInput(input, {required} as core.InputOptions)
|
||||
}
|
||||
|
||||
public getListInput(input: string, required?: boolean): string[] {
|
||||
return core
|
||||
.getInput(input, { required } as core.InputOptions)
|
||||
.split("\n")
|
||||
.filter(x => x !== "");
|
||||
.getInput(input, {required} as core.InputOptions)
|
||||
.split('\n')
|
||||
.filter(x => x !== '')
|
||||
}
|
||||
|
||||
public getBooleanInput(input: string, required?: boolean): boolean {
|
||||
const inputValue = this.getInput(input, required);
|
||||
return (inputValue || "false").toLowerCase() === "true";
|
||||
const inputValue = this.getInput(input, required)
|
||||
return (inputValue || 'false').toLowerCase() === 'true'
|
||||
}
|
||||
|
||||
public isValidInputFile(input: string, file: string): boolean {
|
||||
return this.filePathSupplied(input) && this.fileExists(file);
|
||||
return this.filePathSupplied(input) && this.fileExists(file)
|
||||
}
|
||||
|
||||
public filePathSupplied(file: string): boolean {
|
||||
const pathValue = path.resolve(this.getInput(file) || "");
|
||||
const repoRoot = this.getSourceDir();
|
||||
return pathValue !== repoRoot;
|
||||
const pathValue = path.resolve(this.getInput(file) || '')
|
||||
const repoRoot = this.getSourceDir()
|
||||
return pathValue !== repoRoot
|
||||
}
|
||||
|
||||
public fileExists(file: string): boolean {
|
||||
return this._exist(file) && this._stats(file).isFile();
|
||||
return this._exist(file) && this._stats(file).isFile()
|
||||
}
|
||||
|
||||
public directoryExists(file: string): boolean {
|
||||
return this._exist(file) && this._stats(file).isDirectory();
|
||||
return this._exist(file) && this._stats(file).isDirectory()
|
||||
}
|
||||
|
||||
private _exist(file: string): boolean {
|
||||
let exist = false;
|
||||
let exist = false
|
||||
try {
|
||||
exist = !!(file && fs.statSync(file) != null);
|
||||
exist = !!(file && fs.statSync(file) != null)
|
||||
} catch (err) {
|
||||
if (err && err.code === "ENOENT") {
|
||||
exist = false;
|
||||
if (err && err.code === 'ENOENT') {
|
||||
exist = false
|
||||
} else {
|
||||
throw err;
|
||||
throw err
|
||||
}
|
||||
}
|
||||
return exist;
|
||||
return exist
|
||||
}
|
||||
|
||||
private _stats(file: string): fs.Stats {
|
||||
return fs.statSync(file);
|
||||
return fs.statSync(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
BuildAgent,
|
||||
};
|
||||
export {BuildAgent}
|
||||
|
||||
@@ -1,109 +1,111 @@
|
||||
import { injectable } from "inversify";
|
||||
import {injectable} from 'inversify'
|
||||
|
||||
import { IBuildAgent, IExecResult } from "../../core/models";
|
||||
import {IBuildAgent, IExecResult} from '../../core/models'
|
||||
|
||||
@injectable()
|
||||
class BuildAgent implements IBuildAgent {
|
||||
|
||||
public get agentName(): string {
|
||||
console.log("getAgentName");
|
||||
return "Mock";
|
||||
console.log('getAgentName')
|
||||
return 'Mock'
|
||||
}
|
||||
|
||||
public find(toolName: string, versionSpec: string, arch?: string): string {
|
||||
console.log("find");
|
||||
return "find";
|
||||
console.log('find')
|
||||
return 'find'
|
||||
}
|
||||
|
||||
public cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string> {
|
||||
console.log("cacheDir");
|
||||
return Promise.resolve("cacheDir");
|
||||
public cacheDir(
|
||||
sourceDir: string,
|
||||
tool: string,
|
||||
version: string,
|
||||
arch?: string
|
||||
): Promise<string> {
|
||||
console.log('cacheDir')
|
||||
return Promise.resolve('cacheDir')
|
||||
}
|
||||
|
||||
public createTempDir(): Promise<string> {
|
||||
console.log("createTempDir");
|
||||
return Promise.resolve("createTempDir");
|
||||
console.log('createTempDir')
|
||||
return Promise.resolve('createTempDir')
|
||||
}
|
||||
|
||||
public debug(message: string): void {
|
||||
console.log("debug");
|
||||
console.log('debug')
|
||||
}
|
||||
|
||||
public setFailed(message: string, done?: boolean): void {
|
||||
console.log("setFailed");
|
||||
console.log('setFailed')
|
||||
}
|
||||
|
||||
public setSucceeded(message: string, done?: boolean): void {
|
||||
console.log("setSucceeded");
|
||||
console.log('setSucceeded')
|
||||
}
|
||||
|
||||
public exportVariable(name: string, val: string): void {
|
||||
console.log("exportVariable");
|
||||
console.log('exportVariable')
|
||||
}
|
||||
|
||||
public getVariable(name: string): string {
|
||||
console.log("getVariable");
|
||||
return "getVariable";
|
||||
console.log('getVariable')
|
||||
return 'getVariable'
|
||||
}
|
||||
|
||||
public addPath(inputPath: string): void {
|
||||
console.log("addPath");
|
||||
console.log('addPath')
|
||||
}
|
||||
|
||||
public which(tool: string, check?: boolean): Promise<string> {
|
||||
console.log("which");
|
||||
return Promise.resolve("which");
|
||||
console.log('which')
|
||||
return Promise.resolve('which')
|
||||
}
|
||||
|
||||
public exec(exec: string, args: string[]): Promise<IExecResult> {
|
||||
return Promise.resolve({
|
||||
code: 0,
|
||||
error: null,
|
||||
stderr: "result.stderr",
|
||||
stdout: "result.stdout",
|
||||
});
|
||||
stderr: 'result.stderr',
|
||||
stdout: 'result.stdout'
|
||||
})
|
||||
}
|
||||
|
||||
public getSourceDir(): string {
|
||||
console.log("getSourceDir");
|
||||
return "getSourceDir";
|
||||
console.log('getSourceDir')
|
||||
return 'getSourceDir'
|
||||
}
|
||||
|
||||
public setOutput(name: string, value: string): void {
|
||||
console.log("setOutput");
|
||||
console.log('setOutput')
|
||||
}
|
||||
|
||||
public getInput(input: string, required?: boolean): string {
|
||||
console.log("getInput");
|
||||
return "getInput";
|
||||
console.log('getInput')
|
||||
return 'getInput'
|
||||
}
|
||||
|
||||
public getListInput(input: string, required?: boolean): string[] {
|
||||
console.log("getListInput");
|
||||
return ["getInput"];
|
||||
console.log('getListInput')
|
||||
return ['getInput']
|
||||
}
|
||||
|
||||
public getBooleanInput(input: string, required?: boolean): boolean {
|
||||
console.log("getBooleanInput");
|
||||
return false;
|
||||
console.log('getBooleanInput')
|
||||
return false
|
||||
}
|
||||
|
||||
public isValidInputFile(input: string, file: string) {
|
||||
console.log("isValidInputFile");
|
||||
return false;
|
||||
console.log('isValidInputFile')
|
||||
return false
|
||||
}
|
||||
|
||||
public fileExists(file: string) {
|
||||
console.log("fileExists");
|
||||
return false;
|
||||
console.log('fileExists')
|
||||
return false
|
||||
}
|
||||
|
||||
public directoryExists(file: string) {
|
||||
console.log("directoryExists");
|
||||
return false;
|
||||
console.log('directoryExists')
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
BuildAgent,
|
||||
};
|
||||
export {BuildAgent}
|
||||
|
||||
@@ -1,68 +1,76 @@
|
||||
import * as fs from "fs";
|
||||
import * as os from "os";
|
||||
import * as path from "path";
|
||||
import * as http from "typed-rest-client/HttpClient";
|
||||
import * as fs from 'fs'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import * as http from 'typed-rest-client/HttpClient'
|
||||
|
||||
import { inject, injectable } from "inversify";
|
||||
import { TYPES, IExecResult, IBuildAgent } from "./models";
|
||||
import { IVersionManager } from "./versionManager";
|
||||
import {inject, injectable} from 'inversify'
|
||||
import {TYPES, IExecResult, IBuildAgent} from './models'
|
||||
import {IVersionManager} from './versionManager'
|
||||
|
||||
export interface IDotnetTool {
|
||||
disableTelemetry(): void;
|
||||
toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean): Promise<string>;
|
||||
disableTelemetry(): void
|
||||
toolInstall(
|
||||
toolName: string,
|
||||
versionSpec: string,
|
||||
checkLatest: boolean,
|
||||
includePre: boolean
|
||||
): Promise<string>
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class DotnetTool implements IDotnetTool {
|
||||
|
||||
protected buildAgent: IBuildAgent;
|
||||
protected versionManager: IVersionManager;
|
||||
private httpClient: http.HttpClient;
|
||||
protected buildAgent: IBuildAgent
|
||||
protected versionManager: IVersionManager
|
||||
private httpClient: http.HttpClient
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
|
||||
@inject(TYPES.IVersionManager) versionManager: IVersionManager,
|
||||
@inject(TYPES.IVersionManager) versionManager: IVersionManager
|
||||
) {
|
||||
this.buildAgent = buildAgent;
|
||||
this.versionManager = versionManager;
|
||||
this.httpClient = new http.HttpClient("dotnet");
|
||||
this.buildAgent = buildAgent
|
||||
this.versionManager = versionManager
|
||||
this.httpClient = new http.HttpClient('dotnet')
|
||||
}
|
||||
|
||||
public disableTelemetry(): void {
|
||||
this.buildAgent.exportVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1");
|
||||
this.buildAgent.exportVariable('DOTNET_CLI_TELEMETRY_OPTOUT', '1')
|
||||
}
|
||||
|
||||
public execute(cmd: string, args: string[]): Promise<IExecResult> {
|
||||
console.log(`Command: ${cmd} ${args.join(' ')}`);
|
||||
return this.buildAgent.exec(cmd, args);
|
||||
console.log(`Command: ${cmd} ${args.join(' ')}`)
|
||||
return this.buildAgent.exec(cmd, args)
|
||||
}
|
||||
|
||||
public async toolInstall(toolName: string, versionSpec: string, checkLatest: boolean, includePre: boolean)
|
||||
: Promise<string> {
|
||||
console.log("");
|
||||
console.log("--------------------------");
|
||||
console.log(`Installing ${toolName} version ` + versionSpec);
|
||||
console.log("--------------------------");
|
||||
public async toolInstall(
|
||||
toolName: string,
|
||||
versionSpec: string,
|
||||
checkLatest: boolean,
|
||||
includePre: boolean
|
||||
): Promise<string> {
|
||||
console.log('')
|
||||
console.log('--------------------------')
|
||||
console.log(`Installing ${toolName} version ` + versionSpec)
|
||||
console.log('--------------------------')
|
||||
|
||||
if (this.versionManager.isExplicitVersion(versionSpec)) {
|
||||
checkLatest = false; // check latest doesn't make sense when explicit version
|
||||
checkLatest = false // check latest doesn't make sense when explicit version
|
||||
}
|
||||
|
||||
let toolPath: string;
|
||||
let toolPath: string
|
||||
if (!checkLatest) {
|
||||
//
|
||||
// Let's try and resolve the version spec locally first
|
||||
//
|
||||
toolPath = this.buildAgent.find(toolName, versionSpec);
|
||||
toolPath = this.buildAgent.find(toolName, versionSpec)
|
||||
}
|
||||
|
||||
if (!toolPath) {
|
||||
let version: string;
|
||||
let version: string
|
||||
if (this.versionManager.isExplicitVersion(versionSpec)) {
|
||||
//
|
||||
// Explicit version was specified. No need to query for list of versions.
|
||||
//
|
||||
version = versionSpec;
|
||||
version = versionSpec
|
||||
} else {
|
||||
//
|
||||
// Let's query and resolve the latest version for the versionSpec.
|
||||
@@ -70,21 +78,27 @@ export class DotnetTool implements IDotnetTool {
|
||||
// If your tool doesn't offer a mechanism to query,
|
||||
// then it can only support exact version inputs.
|
||||
//
|
||||
version = await this.queryLatestMatch(toolName, versionSpec, includePre);
|
||||
version = await this.queryLatestMatch(
|
||||
toolName,
|
||||
versionSpec,
|
||||
includePre
|
||||
)
|
||||
if (!version) {
|
||||
throw new Error(`Unable to find ${toolName} version '${versionSpec}'.`);
|
||||
throw new Error(
|
||||
`Unable to find ${toolName} version '${versionSpec}'.`
|
||||
)
|
||||
}
|
||||
|
||||
//
|
||||
// Check the cache for the resolved version.
|
||||
//
|
||||
toolPath = this.buildAgent.find(toolName, version);
|
||||
toolPath = this.buildAgent.find(toolName, version)
|
||||
}
|
||||
if (!toolPath) {
|
||||
//
|
||||
// Download, extract, cache
|
||||
//
|
||||
toolPath = await this.acquireTool(toolName, version);
|
||||
toolPath = await this.acquireTool(toolName, version)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,62 +106,79 @@ export class DotnetTool implements IDotnetTool {
|
||||
// Prepend the tools path. This prepends the PATH for the current process and
|
||||
// instructs the agent to prepend for each task that follows.
|
||||
//
|
||||
this.buildAgent.debug(`toolPath: ${toolPath}`);
|
||||
this.buildAgent.debug(`toolPath: ${toolPath}`)
|
||||
|
||||
if (os.platform() !== "win32" && !this.buildAgent.getVariable("DOTNET_ROOT")) {
|
||||
let dotnetPath = await this.buildAgent.which("dotnet");
|
||||
dotnetPath = fs.readlinkSync(dotnetPath) || dotnetPath;
|
||||
const dotnetRoot = path.dirname(dotnetPath);
|
||||
this.buildAgent.exportVariable("DOTNET_ROOT", dotnetRoot);
|
||||
if (
|
||||
os.platform() !== 'win32' &&
|
||||
!this.buildAgent.getVariable('DOTNET_ROOT')
|
||||
) {
|
||||
let dotnetPath = await this.buildAgent.which('dotnet')
|
||||
dotnetPath = fs.readlinkSync(dotnetPath) || dotnetPath
|
||||
const dotnetRoot = path.dirname(dotnetPath)
|
||||
this.buildAgent.exportVariable('DOTNET_ROOT', dotnetRoot)
|
||||
}
|
||||
this.buildAgent.addPath(toolPath);
|
||||
this.buildAgent.addPath(toolPath)
|
||||
|
||||
return toolPath;
|
||||
return toolPath
|
||||
}
|
||||
|
||||
private async queryLatestMatch(toolName: string, versionSpec: string, includePrerelease: boolean): Promise<string> {
|
||||
this.buildAgent.debug(`querying tool versions for ${toolName}${versionSpec ? `@${versionSpec}` : ""} ${includePrerelease ? "including pre-releases" : ""}`);
|
||||
private async queryLatestMatch(
|
||||
toolName: string,
|
||||
versionSpec: string,
|
||||
includePrerelease: boolean
|
||||
): Promise<string> {
|
||||
this.buildAgent.debug(
|
||||
`querying tool versions for ${toolName}${
|
||||
versionSpec ? `@${versionSpec}` : ''
|
||||
} ${includePrerelease ? 'including pre-releases' : ''}`
|
||||
)
|
||||
|
||||
const downloadPath = `https://api-v2v3search-0.nuget.org/query?q=${encodeURIComponent(toolName.toLowerCase())}&prerelease=${includePrerelease ? "true" : "false"}&semVerLevel=2.0.0`;
|
||||
const res = await this.httpClient.get(downloadPath);
|
||||
const downloadPath = `https://api-v2v3search-0.nuget.org/query?q=${encodeURIComponent(
|
||||
toolName.toLowerCase()
|
||||
)}&prerelease=${includePrerelease ? 'true' : 'false'}&semVerLevel=2.0.0`
|
||||
const res = await this.httpClient.get(downloadPath)
|
||||
|
||||
if (!res || res.message.statusCode !== 200) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
|
||||
const body: string = await res.readBody();
|
||||
const data = JSON.parse(body).data;
|
||||
const body: string = await res.readBody()
|
||||
const data = JSON.parse(body).data
|
||||
|
||||
const versions = (data[0].versions as { version: string }[]).map((x) => x.version);
|
||||
const versions = (data[0].versions as {version: string}[]).map(
|
||||
x => x.version
|
||||
)
|
||||
if (!versions || !versions.length) {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
|
||||
this.buildAgent.debug(`got versions: ${versions.join(", ")}`);
|
||||
this.buildAgent.debug(`got versions: ${versions.join(', ')}`)
|
||||
|
||||
return this.versionManager.evaluateVersions(versions, versionSpec);
|
||||
return this.versionManager.evaluateVersions(versions, versionSpec)
|
||||
}
|
||||
|
||||
private async acquireTool(toolName: string, version: string): Promise<string> {
|
||||
|
||||
const tempDirectory = await this.buildAgent.createTempDir();
|
||||
let args = ["tool", "install", toolName, "--tool-path", tempDirectory];
|
||||
private async acquireTool(
|
||||
toolName: string,
|
||||
version: string
|
||||
): Promise<string> {
|
||||
const tempDirectory = await this.buildAgent.createTempDir()
|
||||
let args = ['tool', 'install', toolName, '--tool-path', tempDirectory]
|
||||
|
||||
if (version) {
|
||||
version = this.versionManager.cleanVersion(version);
|
||||
args = args.concat(["--version", version]);
|
||||
version = this.versionManager.cleanVersion(version)
|
||||
args = args.concat(['--version', version])
|
||||
}
|
||||
|
||||
const result = await this.execute("dotnet", args);
|
||||
const status = result.code === 0 ? "success" : "failure";
|
||||
const message = result.code === 0 ? result.stdout : result.stderr;
|
||||
const result = await this.execute('dotnet', args)
|
||||
const status = result.code === 0 ? 'success' : 'failure'
|
||||
const message = result.code === 0 ? result.stdout : result.stderr
|
||||
|
||||
this.buildAgent.debug(`tool install result: ${status} ${message}`);
|
||||
this.buildAgent.debug(`tool install result: ${status} ${message}`)
|
||||
|
||||
if (result.code) {
|
||||
throw new Error("Error installing tool");
|
||||
throw new Error('Error installing tool')
|
||||
}
|
||||
|
||||
return await this.buildAgent.cacheDir(tempDirectory, toolName, version);
|
||||
return await this.buildAgent.cacheDir(tempDirectory, toolName, version)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Container } from "inversify";
|
||||
import { IVersionManager, VersionManager } from "./versionManager";
|
||||
import { TYPES, IBuildAgent } from "./models";
|
||||
import { BuildAgent } from "../agent/mock/build-agent";
|
||||
import {Container} from 'inversify'
|
||||
import {IVersionManager, VersionManager} from './versionManager'
|
||||
import {TYPES, IBuildAgent} from './models'
|
||||
import {BuildAgent} from '../agent/mock/build-agent'
|
||||
|
||||
const container = new Container();
|
||||
const container = new Container()
|
||||
|
||||
container.bind<IVersionManager>(TYPES.IVersionManager).to(VersionManager);
|
||||
container.bind<IBuildAgent>(TYPES.IBuildAgent).to(BuildAgent);
|
||||
container.bind<IVersionManager>(TYPES.IVersionManager).to(VersionManager)
|
||||
container.bind<IBuildAgent>(TYPES.IBuildAgent).to(BuildAgent)
|
||||
|
||||
export default container;
|
||||
export default container
|
||||
|
||||
@@ -1,49 +1,54 @@
|
||||
export const TYPES = {
|
||||
IBuildAgent: Symbol.for("BuildAgent"),
|
||||
IDotnetTool: Symbol.for("DotnetTool"),
|
||||
IGitVersionTool: Symbol.for("GitVersionTool"),
|
||||
IGitReleaseManagerTool: Symbol.for("GitReleaseManagerTool"),
|
||||
IVersionManager: Symbol.for("VersionManager"),
|
||||
};
|
||||
IBuildAgent: Symbol.for('BuildAgent'),
|
||||
IDotnetTool: Symbol.for('DotnetTool'),
|
||||
IGitVersionTool: Symbol.for('GitVersionTool'),
|
||||
IGitReleaseManagerTool: Symbol.for('GitReleaseManagerTool'),
|
||||
IVersionManager: Symbol.for('VersionManager')
|
||||
}
|
||||
|
||||
export enum SetupFields {
|
||||
includePrerelease = "includePrerelease",
|
||||
versionSpec = "versionSpec",
|
||||
};
|
||||
includePrerelease = 'includePrerelease',
|
||||
versionSpec = 'versionSpec'
|
||||
}
|
||||
|
||||
export interface ISetupSettings {
|
||||
[SetupFields.versionSpec]: string;
|
||||
[SetupFields.includePrerelease]: boolean;
|
||||
[SetupFields.versionSpec]: string
|
||||
[SetupFields.includePrerelease]: boolean
|
||||
}
|
||||
|
||||
export interface IExecResult {
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
code: number;
|
||||
error: Error;
|
||||
stdout: string
|
||||
stderr: string
|
||||
code: number
|
||||
error: Error
|
||||
}
|
||||
|
||||
export interface IBuildAgent {
|
||||
agentName: string;
|
||||
find(toolName: string, versionSpec: string, arch?: string): string;
|
||||
cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string>;
|
||||
createTempDir(): Promise<string>;
|
||||
debug(message: string): void;
|
||||
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>;
|
||||
agentName: string
|
||||
find(toolName: string, versionSpec: string, arch?: string): string
|
||||
cacheDir(
|
||||
sourceDir: string,
|
||||
tool: string,
|
||||
version: string,
|
||||
arch?: string
|
||||
): Promise<string>
|
||||
createTempDir(): Promise<string>
|
||||
debug(message: string): void
|
||||
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>
|
||||
|
||||
getSourceDir(): string;
|
||||
isValidInputFile(input: string, file: string): boolean;
|
||||
fileExists(file: string): boolean;
|
||||
directoryExists(file: string): boolean;
|
||||
getSourceDir(): string
|
||||
isValidInputFile(input: string, file: string): boolean
|
||||
fileExists(file: string): boolean
|
||||
directoryExists(file: string): boolean
|
||||
|
||||
setOutput(name: string, value: string): void;
|
||||
getInput(input: string, required?: boolean): string;
|
||||
getListInput(input: string, required?: boolean): string[];
|
||||
getBooleanInput(input: string, required?: boolean): boolean;
|
||||
}
|
||||
setOutput(name: string, value: string): void
|
||||
getInput(input: string, required?: boolean): string
|
||||
getListInput(input: string, required?: boolean): string[]
|
||||
getBooleanInput(input: string, required?: boolean): boolean
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { IBuildAgent, SetupFields, ISetupSettings } from "./models";
|
||||
import {IBuildAgent, SetupFields, ISetupSettings} from './models'
|
||||
|
||||
export class Settings {
|
||||
|
||||
public static getSetupSettings(buildAgent: IBuildAgent): ISetupSettings {
|
||||
const versionSpec = buildAgent.getInput(SetupFields.versionSpec);
|
||||
const includePrerelease = buildAgent.getBooleanInput(SetupFields.includePrerelease);
|
||||
const versionSpec = buildAgent.getInput(SetupFields.versionSpec)
|
||||
const includePrerelease = buildAgent.getBooleanInput(
|
||||
SetupFields.includePrerelease
|
||||
)
|
||||
|
||||
return {
|
||||
versionSpec,
|
||||
includePrerelease
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +1,56 @@
|
||||
import cmp from "semver-compare";
|
||||
import * as semver from "semver";
|
||||
import { injectable, inject } from "inversify";
|
||||
import cmp from 'semver-compare'
|
||||
import * as semver from 'semver'
|
||||
import {injectable, inject} from 'inversify'
|
||||
|
||||
import { IBuildAgent, TYPES } from "./models";
|
||||
import {IBuildAgent, TYPES} from './models'
|
||||
|
||||
export interface IVersionManager {
|
||||
isExplicitVersion(versionSpec: string): boolean;
|
||||
evaluateVersions(versions: string[], versionSpec: string): string;
|
||||
cleanVersion(version: string): string;
|
||||
isExplicitVersion(versionSpec: string): boolean
|
||||
evaluateVersions(versions: string[], versionSpec: string): string
|
||||
cleanVersion(version: string): string
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class VersionManager implements IVersionManager {
|
||||
|
||||
private buildAgent: IBuildAgent;
|
||||
constructor(
|
||||
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
|
||||
) {
|
||||
this.buildAgent = buildAgent;
|
||||
private buildAgent: IBuildAgent
|
||||
constructor(@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent) {
|
||||
this.buildAgent = buildAgent
|
||||
}
|
||||
|
||||
public isExplicitVersion(versionSpec: string): boolean {
|
||||
const c = semver.clean(versionSpec);
|
||||
this.buildAgent.debug("isExplicit: " + c);
|
||||
const c = semver.clean(versionSpec)
|
||||
this.buildAgent.debug('isExplicit: ' + c)
|
||||
|
||||
const valid = semver.valid(c) != null;
|
||||
this.buildAgent.debug("explicit? " + valid);
|
||||
const valid = semver.valid(c) != null
|
||||
this.buildAgent.debug('explicit? ' + valid)
|
||||
|
||||
return valid;
|
||||
return valid
|
||||
}
|
||||
|
||||
public evaluateVersions(versions: string[], versionSpec: string): string {
|
||||
let version: string;
|
||||
this.buildAgent.debug("evaluating " + versions.length + " versions");
|
||||
versions = versions.sort(cmp);
|
||||
let version: string
|
||||
this.buildAgent.debug('evaluating ' + versions.length + ' versions')
|
||||
versions = versions.sort(cmp)
|
||||
for (let i = versions.length - 1; i >= 0; i--) {
|
||||
const potential: string = versions[i];
|
||||
const satisfied: boolean = semver.satisfies(potential, versionSpec);
|
||||
if (satisfied) {
|
||||
version = potential;
|
||||
break;
|
||||
const potential: string = versions[i]
|
||||
const satisfied: boolean = semver.satisfies(potential, versionSpec)
|
||||
if (satisfied) {
|
||||
version = potential
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version) {
|
||||
this.buildAgent.debug("matched: " + version);
|
||||
} else {
|
||||
this.buildAgent.debug("match not found");
|
||||
}
|
||||
this.buildAgent.debug('matched: ' + version)
|
||||
} else {
|
||||
this.buildAgent.debug('match not found')
|
||||
}
|
||||
|
||||
return version;
|
||||
return version
|
||||
}
|
||||
|
||||
public cleanVersion(version: string): string {
|
||||
this.buildAgent.debug("cleaning: " + version);
|
||||
return semver.clean(version);
|
||||
this.buildAgent.debug('cleaning: ' + version)
|
||||
return semver.clean(version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { addAsset } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {addAsset} from './main'
|
||||
|
||||
addAsset();
|
||||
addAsset()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { close } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {close} from './main'
|
||||
|
||||
close();
|
||||
close()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { create } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {create} from './main'
|
||||
|
||||
create();
|
||||
create()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { discard } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {discard} from './main'
|
||||
|
||||
discard();
|
||||
discard()
|
||||
|
||||
@@ -1,116 +1,140 @@
|
||||
import { IBuildAgent, TYPES, SetupFields } from "../../core/models";
|
||||
import { IGitReleaseManagerTool, GitReleaseManagerTool } from "../../tools/gitreleasemanager/tool";
|
||||
import { Settings as CommonSettings } from "../../core/settings";
|
||||
import { Settings } from "../../tools/gitreleasemanager/settings";
|
||||
import {IBuildAgent, TYPES, SetupFields} from '../../core/models'
|
||||
import {
|
||||
IGitReleaseManagerTool,
|
||||
GitReleaseManagerTool
|
||||
} from '../../tools/gitreleasemanager/tool'
|
||||
import {Settings as CommonSettings} from '../../core/settings'
|
||||
import {Settings} from '../../tools/gitreleasemanager/settings'
|
||||
|
||||
import container from "../../core/ioc";
|
||||
import container from '../../core/ioc'
|
||||
|
||||
container.bind<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool).to(GitReleaseManagerTool);
|
||||
container
|
||||
.bind<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool)
|
||||
.to(GitReleaseManagerTool)
|
||||
|
||||
const gitReleaseManagerTool = container.get<IGitReleaseManagerTool>(TYPES.IGitReleaseManagerTool);
|
||||
const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent);
|
||||
const gitReleaseManagerTool = container.get<IGitReleaseManagerTool>(
|
||||
TYPES.IGitReleaseManagerTool
|
||||
)
|
||||
const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent)
|
||||
|
||||
export async function setup() {
|
||||
try {
|
||||
gitReleaseManagerTool.disableTelemetry()
|
||||
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
const settings = CommonSettings.getSetupSettings(buildAgent)
|
||||
|
||||
const settings = CommonSettings.getSetupSettings(buildAgent);
|
||||
await gitReleaseManagerTool.install(
|
||||
settings.versionSpec,
|
||||
settings.includePrerelease
|
||||
)
|
||||
|
||||
await gitReleaseManagerTool.install(settings.versionSpec, settings.includePrerelease);
|
||||
|
||||
buildAgent.setSucceeded("GitVersionManager installed successfully", true);
|
||||
buildAgent.setSucceeded(
|
||||
'GitVersionManager installed successfully',
|
||||
true
|
||||
)
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
buildAgent.setFailed(error.message, true)
|
||||
}
|
||||
}
|
||||
|
||||
export async function create() {
|
||||
try {
|
||||
gitReleaseManagerTool.disableTelemetry()
|
||||
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
const settings = Settings.getCreateSettings(buildAgent)
|
||||
|
||||
const settings = Settings.getCreateSettings(buildAgent);
|
||||
await gitReleaseManagerTool.create(settings)
|
||||
|
||||
await gitReleaseManagerTool.create(settings);
|
||||
|
||||
buildAgent.setSucceeded("GitVersionManager created release successfully", true);
|
||||
buildAgent.setSucceeded(
|
||||
'GitVersionManager created release successfully',
|
||||
true
|
||||
)
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
buildAgent.setFailed(error.message, true)
|
||||
}
|
||||
}
|
||||
|
||||
export async function discard() {
|
||||
try {
|
||||
gitReleaseManagerTool.disableTelemetry()
|
||||
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
const settings = Settings.getDiscardSettings(buildAgent)
|
||||
|
||||
const settings = Settings.getDiscardSettings(buildAgent);
|
||||
await gitReleaseManagerTool.discard(settings)
|
||||
|
||||
await gitReleaseManagerTool.discard(settings);
|
||||
|
||||
buildAgent.setSucceeded("GitVersionManager discarded release successfully", true);
|
||||
buildAgent.setSucceeded(
|
||||
'GitVersionManager discarded release successfully',
|
||||
true
|
||||
)
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
buildAgent.setFailed(error.message, true)
|
||||
}
|
||||
}
|
||||
|
||||
export async function close() {
|
||||
try {
|
||||
gitReleaseManagerTool.disableTelemetry()
|
||||
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
const settings = Settings.getCloseSettings(buildAgent)
|
||||
|
||||
const settings = Settings.getCloseSettings(buildAgent);
|
||||
await gitReleaseManagerTool.close(settings)
|
||||
|
||||
await gitReleaseManagerTool.close(settings);
|
||||
|
||||
buildAgent.setSucceeded("GitVersionManager closed release successfully", true);
|
||||
buildAgent.setSucceeded(
|
||||
'GitVersionManager closed release successfully',
|
||||
true
|
||||
)
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
buildAgent.setFailed(error.message, true)
|
||||
}
|
||||
}
|
||||
|
||||
export async function open() {
|
||||
try {
|
||||
gitReleaseManagerTool.disableTelemetry()
|
||||
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
const settings = Settings.getOpenSettings(buildAgent)
|
||||
|
||||
const settings = Settings.getOpenSettings(buildAgent);
|
||||
await gitReleaseManagerTool.open(settings)
|
||||
|
||||
await gitReleaseManagerTool.open(settings);
|
||||
|
||||
buildAgent.setSucceeded("GitVersionManager opened release successfully", true);
|
||||
buildAgent.setSucceeded(
|
||||
'GitVersionManager opened release successfully',
|
||||
true
|
||||
)
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
buildAgent.setFailed(error.message, true)
|
||||
}
|
||||
}
|
||||
|
||||
export async function publish() {
|
||||
try {
|
||||
gitReleaseManagerTool.disableTelemetry()
|
||||
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
const settings = Settings.getPublishSettings(buildAgent)
|
||||
|
||||
const settings = Settings.getPublishSettings(buildAgent);
|
||||
await gitReleaseManagerTool.publish(settings)
|
||||
|
||||
await gitReleaseManagerTool.publish(settings);
|
||||
|
||||
buildAgent.setSucceeded("GitVersionManager published release successfully", true);
|
||||
buildAgent.setSucceeded(
|
||||
'GitVersionManager published release successfully',
|
||||
true
|
||||
)
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
buildAgent.setFailed(error.message, true)
|
||||
}
|
||||
}
|
||||
|
||||
export async function addAsset() {
|
||||
try {
|
||||
gitReleaseManagerTool.disableTelemetry()
|
||||
|
||||
gitReleaseManagerTool.disableTelemetry();
|
||||
const settings = Settings.getAddAssetSettings(buildAgent)
|
||||
|
||||
const settings = Settings.getAddAssetSettings(buildAgent);
|
||||
await gitReleaseManagerTool.addAsset(settings)
|
||||
|
||||
await gitReleaseManagerTool.addAsset(settings);
|
||||
|
||||
buildAgent.setSucceeded("GitVersionManager added assets to release successfully", true);
|
||||
buildAgent.setSucceeded(
|
||||
'GitVersionManager added assets to release successfully',
|
||||
true
|
||||
)
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
buildAgent.setFailed(error.message, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { open } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {open} from './main'
|
||||
|
||||
open();
|
||||
open()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { publish } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {publish} from './main'
|
||||
|
||||
publish();
|
||||
publish()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { setup } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {setup} from './main'
|
||||
|
||||
setup();
|
||||
setup()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { run } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {run} from './main'
|
||||
|
||||
run();
|
||||
run()
|
||||
|
||||
@@ -1,50 +1,55 @@
|
||||
import { IBuildAgent, TYPES, SetupFields } from "../../core/models";
|
||||
import { Settings as CommonSettings } from "../../core/settings";
|
||||
import { Settings } from "../../tools/gitversion/settings";
|
||||
import { IGitVersionTool, GitVersionTool } from "../../tools/gitversion/tool";
|
||||
import { GitVersionSettings, GitVersionOutput } from "../../tools/gitversion/models";
|
||||
import {IBuildAgent, TYPES, SetupFields} from '../../core/models'
|
||||
import {Settings as CommonSettings} from '../../core/settings'
|
||||
import {Settings} from '../../tools/gitversion/settings'
|
||||
import {IGitVersionTool, GitVersionTool} from '../../tools/gitversion/tool'
|
||||
import {
|
||||
GitVersionSettings,
|
||||
GitVersionOutput
|
||||
} from '../../tools/gitversion/models'
|
||||
|
||||
import container from "../../core/ioc";
|
||||
import container from '../../core/ioc'
|
||||
|
||||
container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool);
|
||||
container.bind<IGitVersionTool>(TYPES.IGitVersionTool).to(GitVersionTool)
|
||||
|
||||
const gitVersionTool = container.get<IGitVersionTool>(TYPES.IGitVersionTool);
|
||||
const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent);
|
||||
const gitVersionTool = container.get<IGitVersionTool>(TYPES.IGitVersionTool)
|
||||
const buildAgent = container.get<IBuildAgent>(TYPES.IBuildAgent)
|
||||
|
||||
export async function setup() {
|
||||
try {
|
||||
gitVersionTool.disableTelemetry()
|
||||
|
||||
gitVersionTool.disableTelemetry();
|
||||
const settings = CommonSettings.getSetupSettings(buildAgent)
|
||||
|
||||
const settings = CommonSettings.getSetupSettings(buildAgent);
|
||||
await gitVersionTool.install(
|
||||
settings.versionSpec,
|
||||
settings.includePrerelease
|
||||
)
|
||||
|
||||
await gitVersionTool.install(settings.versionSpec, settings.includePrerelease);
|
||||
|
||||
buildAgent.setSucceeded("GitVersion installed successfully", true);
|
||||
buildAgent.setSucceeded('GitVersion installed successfully', true)
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error.message, true);
|
||||
buildAgent.setFailed(error.message, true)
|
||||
}
|
||||
}
|
||||
|
||||
export async function run() {
|
||||
try {
|
||||
gitVersionTool.disableTelemetry()
|
||||
|
||||
gitVersionTool.disableTelemetry();
|
||||
const settings: GitVersionSettings = Settings.getGitVersionSettings(
|
||||
buildAgent
|
||||
)
|
||||
|
||||
const settings: GitVersionSettings = Settings.getGitVersionSettings(buildAgent);
|
||||
const result = await gitVersionTool.run(settings)
|
||||
|
||||
const result = await gitVersionTool.run(settings);
|
||||
|
||||
const gitversion = JSON.parse(result.stdout) as GitVersionOutput;
|
||||
gitVersionTool.writeGitVersionToAgent(gitversion);
|
||||
const gitversion = JSON.parse(result.stdout) as GitVersionOutput
|
||||
gitVersionTool.writeGitVersionToAgent(gitversion)
|
||||
|
||||
if (result.code === 0) {
|
||||
buildAgent.setSucceeded("GitVersion executed successfully", true);
|
||||
buildAgent.setSucceeded('GitVersion executed successfully', true)
|
||||
} else {
|
||||
buildAgent.setFailed(result.error.message, true);
|
||||
buildAgent.setFailed(result.error.message, true)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
buildAgent.setFailed(error, true);
|
||||
buildAgent.setFailed(error, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import "reflect-metadata";
|
||||
import { setup } from "./main";
|
||||
import 'reflect-metadata'
|
||||
import {setup} from './main'
|
||||
|
||||
setup();
|
||||
setup()
|
||||
|
||||
@@ -1,73 +1,79 @@
|
||||
export enum CommonFields {
|
||||
repository = "repository",
|
||||
owner = "owner",
|
||||
token = "token",
|
||||
targetDirectory = "targetDirectory",
|
||||
repository = 'repository',
|
||||
owner = 'owner',
|
||||
token = 'token',
|
||||
targetDirectory = 'targetDirectory'
|
||||
}
|
||||
|
||||
export enum CreateFields {
|
||||
milestone = "milestone",
|
||||
name = "name",
|
||||
inputFileName = "inputFileName",
|
||||
isPreRelease = "isPreRelease",
|
||||
commit = "commit",
|
||||
assets = "assets",
|
||||
milestone = 'milestone',
|
||||
name = 'name',
|
||||
inputFileName = 'inputFileName',
|
||||
isPreRelease = 'isPreRelease',
|
||||
commit = 'commit',
|
||||
assets = 'assets'
|
||||
}
|
||||
|
||||
export enum DiscardFields {
|
||||
milestone = "milestone",
|
||||
milestone = 'milestone'
|
||||
}
|
||||
|
||||
export enum CloseFields {
|
||||
milestone = "milestone",
|
||||
milestone = 'milestone'
|
||||
}
|
||||
|
||||
export enum OpenFields {
|
||||
milestone = "milestone",
|
||||
milestone = 'milestone'
|
||||
}
|
||||
|
||||
export enum PublishFields {
|
||||
tagName = "tagName",
|
||||
tagName = 'tagName'
|
||||
}
|
||||
|
||||
export enum AddAssetFields {
|
||||
tagName = "tagName",
|
||||
assets = "assets",
|
||||
tagName = 'tagName',
|
||||
assets = 'assets'
|
||||
}
|
||||
|
||||
export interface GitReleaseManagerSettings {
|
||||
[CommonFields.repository]: string;
|
||||
[CommonFields.owner]: string;
|
||||
[CommonFields.token]: string;
|
||||
[CommonFields.targetDirectory]: string;
|
||||
[CommonFields.repository]: string
|
||||
[CommonFields.owner]: string
|
||||
[CommonFields.token]: string
|
||||
[CommonFields.targetDirectory]: string
|
||||
}
|
||||
|
||||
export interface GitReleaseManagerCreateSettings extends GitReleaseManagerSettings {
|
||||
[CreateFields.milestone]: string;
|
||||
[CreateFields.name]: string;
|
||||
[CreateFields.inputFileName]: string;
|
||||
[CreateFields.isPreRelease]: boolean;
|
||||
[CreateFields.commit]: string;
|
||||
[CreateFields.assets]?: string[];
|
||||
export interface GitReleaseManagerCreateSettings
|
||||
extends GitReleaseManagerSettings {
|
||||
[CreateFields.milestone]: string
|
||||
[CreateFields.name]: string
|
||||
[CreateFields.inputFileName]: string
|
||||
[CreateFields.isPreRelease]: boolean
|
||||
[CreateFields.commit]: string
|
||||
[CreateFields.assets]?: string[]
|
||||
}
|
||||
|
||||
export interface GitReleaseManagerDiscardSettings extends GitReleaseManagerSettings {
|
||||
[DiscardFields.milestone]: string;
|
||||
export interface GitReleaseManagerDiscardSettings
|
||||
extends GitReleaseManagerSettings {
|
||||
[DiscardFields.milestone]: string
|
||||
}
|
||||
|
||||
export interface GitReleaseManagerCloseSettings extends GitReleaseManagerSettings {
|
||||
[CloseFields.milestone]: string;
|
||||
export interface GitReleaseManagerCloseSettings
|
||||
extends GitReleaseManagerSettings {
|
||||
[CloseFields.milestone]: string
|
||||
}
|
||||
|
||||
export interface GitReleaseManagerOpenSettings extends GitReleaseManagerSettings {
|
||||
[OpenFields.milestone]: string;
|
||||
export interface GitReleaseManagerOpenSettings
|
||||
extends GitReleaseManagerSettings {
|
||||
[OpenFields.milestone]: string
|
||||
}
|
||||
|
||||
export interface GitReleaseManagerPublishSettings extends GitReleaseManagerSettings {
|
||||
[PublishFields.tagName]: string;
|
||||
export interface GitReleaseManagerPublishSettings
|
||||
extends GitReleaseManagerSettings {
|
||||
[PublishFields.tagName]: string
|
||||
}
|
||||
|
||||
export interface GitReleaseManagerAddAssetSettings extends GitReleaseManagerSettings {
|
||||
[AddAssetFields.tagName]: string;
|
||||
[AddAssetFields.assets]: string[];
|
||||
export interface GitReleaseManagerAddAssetSettings
|
||||
extends GitReleaseManagerSettings {
|
||||
[AddAssetFields.tagName]: string
|
||||
[AddAssetFields.assets]: string[]
|
||||
}
|
||||
|
||||
@@ -1,29 +1,35 @@
|
||||
import { IBuildAgent } from "../../core/models";
|
||||
import {IBuildAgent} from '../../core/models'
|
||||
import {
|
||||
GitReleaseManagerSettings,
|
||||
CommonFields, CreateFields, DiscardFields,
|
||||
CloseFields, OpenFields, PublishFields,
|
||||
CommonFields,
|
||||
CreateFields,
|
||||
DiscardFields,
|
||||
CloseFields,
|
||||
OpenFields,
|
||||
PublishFields,
|
||||
AddAssetFields,
|
||||
|
||||
GitReleaseManagerCreateSettings,
|
||||
GitReleaseManagerDiscardSettings,
|
||||
GitReleaseManagerCloseSettings,
|
||||
GitReleaseManagerOpenSettings,
|
||||
GitReleaseManagerPublishSettings,
|
||||
GitReleaseManagerAddAssetSettings,
|
||||
} from "./models";
|
||||
GitReleaseManagerAddAssetSettings
|
||||
} from './models'
|
||||
|
||||
export class Settings {
|
||||
public static getCreateSettings(
|
||||
buildAgent: IBuildAgent
|
||||
): GitReleaseManagerCreateSettings {
|
||||
const milestone = buildAgent.getInput(CreateFields.milestone)
|
||||
const name = buildAgent.getInput(CreateFields.name)
|
||||
const inputFileName = buildAgent.getInput(CreateFields.inputFileName)
|
||||
const isPreRelease = buildAgent.getBooleanInput(
|
||||
CreateFields.isPreRelease
|
||||
)
|
||||
const commit = buildAgent.getInput(CreateFields.commit)
|
||||
const assets = buildAgent.getListInput(CreateFields.assets)
|
||||
|
||||
public static getCreateSettings(buildAgent: IBuildAgent): GitReleaseManagerCreateSettings {
|
||||
const milestone = buildAgent.getInput(CreateFields.milestone);
|
||||
const name = buildAgent.getInput(CreateFields.name);
|
||||
const inputFileName = buildAgent.getInput(CreateFields.inputFileName);
|
||||
const isPreRelease = buildAgent.getBooleanInput(CreateFields.isPreRelease);
|
||||
const commit = buildAgent.getInput(CreateFields.commit);
|
||||
const assets = buildAgent.getListInput(CreateFields.assets);
|
||||
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent);
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent)
|
||||
return {
|
||||
...commonSettings,
|
||||
milestone,
|
||||
@@ -35,51 +41,61 @@ export class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
public static getDiscardSettings(buildAgent: IBuildAgent): GitReleaseManagerDiscardSettings {
|
||||
const milestone = buildAgent.getInput(DiscardFields.milestone);
|
||||
public static getDiscardSettings(
|
||||
buildAgent: IBuildAgent
|
||||
): GitReleaseManagerDiscardSettings {
|
||||
const milestone = buildAgent.getInput(DiscardFields.milestone)
|
||||
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent);
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent)
|
||||
return {
|
||||
...commonSettings,
|
||||
milestone,
|
||||
milestone
|
||||
}
|
||||
}
|
||||
|
||||
public static getCloseSettings(buildAgent: IBuildAgent): GitReleaseManagerCloseSettings {
|
||||
const milestone = buildAgent.getInput(CloseFields.milestone);
|
||||
public static getCloseSettings(
|
||||
buildAgent: IBuildAgent
|
||||
): GitReleaseManagerCloseSettings {
|
||||
const milestone = buildAgent.getInput(CloseFields.milestone)
|
||||
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent);
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent)
|
||||
return {
|
||||
...commonSettings,
|
||||
milestone,
|
||||
milestone
|
||||
}
|
||||
}
|
||||
|
||||
public static getOpenSettings(buildAgent: IBuildAgent): GitReleaseManagerOpenSettings {
|
||||
const milestone = buildAgent.getInput(OpenFields.milestone);
|
||||
public static getOpenSettings(
|
||||
buildAgent: IBuildAgent
|
||||
): GitReleaseManagerOpenSettings {
|
||||
const milestone = buildAgent.getInput(OpenFields.milestone)
|
||||
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent);
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent)
|
||||
return {
|
||||
...commonSettings,
|
||||
milestone,
|
||||
milestone
|
||||
}
|
||||
}
|
||||
|
||||
public static getPublishSettings(buildAgent: IBuildAgent): GitReleaseManagerPublishSettings {
|
||||
const tagName = buildAgent.getInput(PublishFields.tagName);
|
||||
public static getPublishSettings(
|
||||
buildAgent: IBuildAgent
|
||||
): GitReleaseManagerPublishSettings {
|
||||
const tagName = buildAgent.getInput(PublishFields.tagName)
|
||||
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent);
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent)
|
||||
return {
|
||||
...commonSettings,
|
||||
tagName,
|
||||
tagName
|
||||
}
|
||||
}
|
||||
|
||||
public static getAddAssetSettings(buildAgent: IBuildAgent): GitReleaseManagerAddAssetSettings {
|
||||
const tagName = buildAgent.getInput(AddAssetFields.tagName);
|
||||
const assets = buildAgent.getListInput(AddAssetFields.assets);
|
||||
public static getAddAssetSettings(
|
||||
buildAgent: IBuildAgent
|
||||
): GitReleaseManagerAddAssetSettings {
|
||||
const tagName = buildAgent.getInput(AddAssetFields.tagName)
|
||||
const assets = buildAgent.getListInput(AddAssetFields.assets)
|
||||
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent);
|
||||
const commonSettings = Settings.getCommonSettings(buildAgent)
|
||||
return {
|
||||
...commonSettings,
|
||||
tagName,
|
||||
@@ -87,17 +103,21 @@ export class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
private static getCommonSettings(buildAgent: IBuildAgent): GitReleaseManagerSettings {
|
||||
const owner = buildAgent.getInput(CommonFields.owner, true);
|
||||
const repository = buildAgent.getInput(CommonFields.repository, true);
|
||||
const token = buildAgent.getInput(CommonFields.token, true);
|
||||
const targetDirectory = buildAgent.getInput(CommonFields.targetDirectory);
|
||||
private static getCommonSettings(
|
||||
buildAgent: IBuildAgent
|
||||
): GitReleaseManagerSettings {
|
||||
const owner = buildAgent.getInput(CommonFields.owner, true)
|
||||
const repository = buildAgent.getInput(CommonFields.repository, true)
|
||||
const token = buildAgent.getInput(CommonFields.token, true)
|
||||
const targetDirectory = buildAgent.getInput(
|
||||
CommonFields.targetDirectory
|
||||
)
|
||||
|
||||
return {
|
||||
owner,
|
||||
repository,
|
||||
token,
|
||||
targetDirectory,
|
||||
};
|
||||
targetDirectory
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import path = require("path");
|
||||
import path = require('path')
|
||||
|
||||
import { TYPES, IBuildAgent, IExecResult } from "../../core/models";
|
||||
import { injectable, inject } from "inversify";
|
||||
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";
|
||||
import { IVersionManager } from "../../core/versionManager";
|
||||
import {TYPES, IBuildAgent, IExecResult} from '../../core/models'
|
||||
import {injectable, inject} from 'inversify'
|
||||
import {DotnetTool, IDotnetTool} from '../../core/dotnet-tool'
|
||||
import {IVersionManager} from '../../core/versionManager'
|
||||
|
||||
import {
|
||||
GitReleaseManagerSettings,
|
||||
@@ -12,186 +12,222 @@ import {
|
||||
GitReleaseManagerCloseSettings,
|
||||
GitReleaseManagerOpenSettings,
|
||||
GitReleaseManagerPublishSettings,
|
||||
GitReleaseManagerAddAssetSettings,
|
||||
} from "./models";
|
||||
GitReleaseManagerAddAssetSettings
|
||||
} from './models'
|
||||
|
||||
export interface IGitReleaseManagerTool extends IDotnetTool {
|
||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>;
|
||||
discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult>;
|
||||
close(settings: GitReleaseManagerCloseSettings): Promise<IExecResult>;
|
||||
open(settings: GitReleaseManagerOpenSettings): Promise<IExecResult>;
|
||||
publish(settings: GitReleaseManagerPublishSettings): Promise<IExecResult>;
|
||||
addAsset(settings: GitReleaseManagerAddAssetSettings): Promise<IExecResult>;
|
||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>
|
||||
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>
|
||||
discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult>
|
||||
close(settings: GitReleaseManagerCloseSettings): Promise<IExecResult>
|
||||
open(settings: GitReleaseManagerOpenSettings): Promise<IExecResult>
|
||||
publish(settings: GitReleaseManagerPublishSettings): Promise<IExecResult>
|
||||
addAsset(settings: GitReleaseManagerAddAssetSettings): Promise<IExecResult>
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class GitReleaseManagerTool extends DotnetTool implements IGitReleaseManagerTool {
|
||||
|
||||
export class GitReleaseManagerTool extends DotnetTool
|
||||
implements IGitReleaseManagerTool {
|
||||
constructor(
|
||||
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
|
||||
@inject(TYPES.IVersionManager) versionManager: IVersionManager
|
||||
) {
|
||||
super(buildAgent, versionManager);
|
||||
super(buildAgent, versionManager)
|
||||
}
|
||||
|
||||
public async install(versionSpec: string, includePrerelease: boolean): Promise<void> {
|
||||
await this.toolInstall("GitReleaseManager.Tool", versionSpec, false, includePrerelease);
|
||||
public async install(
|
||||
versionSpec: string,
|
||||
includePrerelease: boolean
|
||||
): Promise<void> {
|
||||
await this.toolInstall(
|
||||
'GitReleaseManager.Tool',
|
||||
versionSpec,
|
||||
false,
|
||||
includePrerelease
|
||||
)
|
||||
}
|
||||
|
||||
public create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult> {
|
||||
const args = this.getCreateArguments(settings);
|
||||
public create(
|
||||
settings: GitReleaseManagerCreateSettings
|
||||
): Promise<IExecResult> {
|
||||
const args = this.getCreateArguments(settings)
|
||||
|
||||
return this.execute("dotnet-gitreleasemanager", args);
|
||||
return this.execute('dotnet-gitreleasemanager', args)
|
||||
}
|
||||
|
||||
public discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult> {
|
||||
const args = this.getDiscardArguments(settings);
|
||||
public discard(
|
||||
settings: GitReleaseManagerDiscardSettings
|
||||
): Promise<IExecResult> {
|
||||
const args = this.getDiscardArguments(settings)
|
||||
|
||||
return this.execute("dotnet-gitreleasemanager", args);
|
||||
return this.execute('dotnet-gitreleasemanager', args)
|
||||
}
|
||||
|
||||
public close(settings: GitReleaseManagerCloseSettings): Promise<IExecResult> {
|
||||
const args = this.getCloseArguments(settings);
|
||||
public close(
|
||||
settings: GitReleaseManagerCloseSettings
|
||||
): Promise<IExecResult> {
|
||||
const args = this.getCloseArguments(settings)
|
||||
|
||||
return this.execute("dotnet-gitreleasemanager", args);
|
||||
return this.execute('dotnet-gitreleasemanager', args)
|
||||
}
|
||||
|
||||
public open(settings: GitReleaseManagerOpenSettings): Promise<IExecResult> {
|
||||
const args = this.getOpenArguments(settings);
|
||||
const args = this.getOpenArguments(settings)
|
||||
|
||||
return this.execute("dotnet-gitreleasemanager", args);
|
||||
return this.execute('dotnet-gitreleasemanager', args)
|
||||
}
|
||||
|
||||
public publish(settings: GitReleaseManagerPublishSettings): Promise<IExecResult> {
|
||||
const args = this.getPublishArguments(settings);
|
||||
public publish(
|
||||
settings: GitReleaseManagerPublishSettings
|
||||
): Promise<IExecResult> {
|
||||
const args = this.getPublishArguments(settings)
|
||||
|
||||
return this.execute("dotnet-gitreleasemanager", args);
|
||||
return this.execute('dotnet-gitreleasemanager', args)
|
||||
}
|
||||
|
||||
public addAsset(settings: GitReleaseManagerAddAssetSettings): Promise<IExecResult> {
|
||||
const args = this.getAddAssetArguments(settings);
|
||||
public addAsset(
|
||||
settings: GitReleaseManagerAddAssetSettings
|
||||
): Promise<IExecResult> {
|
||||
const args = this.getAddAssetArguments(settings)
|
||||
|
||||
return this.execute("dotnet-gitreleasemanager", args);
|
||||
return this.execute('dotnet-gitreleasemanager', args)
|
||||
}
|
||||
|
||||
private getCommonArguments(settings: GitReleaseManagerSettings): string[] {
|
||||
const args: string[] = [];
|
||||
const args: string[] = []
|
||||
|
||||
args.push("--owner", settings.owner);
|
||||
args.push("--repository", settings.repository);
|
||||
args.push("--token", settings.token);
|
||||
args.push('--owner', settings.owner)
|
||||
args.push('--repository', settings.repository)
|
||||
args.push('--token', settings.token)
|
||||
|
||||
settings.targetDirectory = this.getRepoDir(settings.targetDirectory);
|
||||
settings.targetDirectory = this.getRepoDir(settings.targetDirectory)
|
||||
|
||||
args.push("--targetDirectory", settings.targetDirectory);
|
||||
args.push('--targetDirectory', settings.targetDirectory)
|
||||
|
||||
return args;
|
||||
return args
|
||||
}
|
||||
|
||||
private getCreateArguments(settings: GitReleaseManagerCreateSettings): string[] {
|
||||
const args: string[] = ['create', ...this.getCommonArguments(settings)];
|
||||
private getCreateArguments(
|
||||
settings: GitReleaseManagerCreateSettings
|
||||
): string[] {
|
||||
const args: string[] = ['create', ...this.getCommonArguments(settings)]
|
||||
|
||||
if (settings.milestone) {
|
||||
args.push("--milestone", settings.milestone);
|
||||
args.push('--milestone', settings.milestone)
|
||||
}
|
||||
if (settings.name) {
|
||||
args.push("--name", settings.name);
|
||||
args.push('--name', settings.name)
|
||||
}
|
||||
if (settings.commit) {
|
||||
args.push("--targetcommitish", settings.commit);
|
||||
args.push('--targetcommitish', settings.commit)
|
||||
}
|
||||
|
||||
if (settings.inputFileName) {
|
||||
if (this.buildAgent.fileExists(settings.inputFileName)) {
|
||||
args.push("--inputFilePath", settings.inputFileName);
|
||||
args.push('--inputFilePath', settings.inputFileName)
|
||||
} else {
|
||||
throw new Error("GitReleaseManager inputFilePath not found at " + settings.inputFileName);
|
||||
throw new Error(
|
||||
'GitReleaseManager inputFilePath not found at ' +
|
||||
settings.inputFileName
|
||||
)
|
||||
}
|
||||
}
|
||||
if (settings.isPreRelease) {
|
||||
args.push("--pre");
|
||||
args.push('--pre')
|
||||
}
|
||||
if (settings.assets && settings.assets.length > 0) {
|
||||
settings.assets = settings.assets.map(asset => {
|
||||
return path.join(settings.targetDirectory, asset)
|
||||
})
|
||||
|
||||
args.push("--assets", settings.assets.join(","));
|
||||
args.push('--assets', settings.assets.join(','))
|
||||
}
|
||||
|
||||
return args;
|
||||
return args
|
||||
}
|
||||
|
||||
private getDiscardArguments(settings: GitReleaseManagerDiscardSettings): string[] {
|
||||
const args: string[] = ['discard', ...this.getCommonArguments(settings)];
|
||||
private getDiscardArguments(
|
||||
settings: GitReleaseManagerDiscardSettings
|
||||
): string[] {
|
||||
const args: string[] = ['discard', ...this.getCommonArguments(settings)]
|
||||
|
||||
if (settings.milestone) {
|
||||
args.push("--milestone", settings.milestone);
|
||||
args.push('--milestone', settings.milestone)
|
||||
}
|
||||
|
||||
return args;
|
||||
return args
|
||||
}
|
||||
|
||||
private getCloseArguments(settings: GitReleaseManagerCloseSettings): string[] {
|
||||
const args: string[] = ['close', ...this.getCommonArguments(settings)];
|
||||
private getCloseArguments(
|
||||
settings: GitReleaseManagerCloseSettings
|
||||
): string[] {
|
||||
const args: string[] = ['close', ...this.getCommonArguments(settings)]
|
||||
|
||||
if (settings.milestone) {
|
||||
args.push("--milestone", settings.milestone);
|
||||
args.push('--milestone', settings.milestone)
|
||||
}
|
||||
|
||||
return args;
|
||||
return args
|
||||
}
|
||||
|
||||
private getOpenArguments(settings: GitReleaseManagerOpenSettings): string[] {
|
||||
const args: string[] = ['open', ...this.getCommonArguments(settings)];
|
||||
private getOpenArguments(
|
||||
settings: GitReleaseManagerOpenSettings
|
||||
): string[] {
|
||||
const args: string[] = ['open', ...this.getCommonArguments(settings)]
|
||||
|
||||
if (settings.milestone) {
|
||||
args.push("--milestone", settings.milestone);
|
||||
args.push('--milestone', settings.milestone)
|
||||
}
|
||||
|
||||
return args;
|
||||
return args
|
||||
}
|
||||
|
||||
private getPublishArguments(settings: GitReleaseManagerPublishSettings): string[] {
|
||||
const args: string[] = ['publish', ...this.getCommonArguments(settings)];
|
||||
private getPublishArguments(
|
||||
settings: GitReleaseManagerPublishSettings
|
||||
): string[] {
|
||||
const args: string[] = ['publish', ...this.getCommonArguments(settings)]
|
||||
|
||||
if (settings.tagName) {
|
||||
args.push("--tagName", settings.tagName);
|
||||
args.push('--tagName', settings.tagName)
|
||||
}
|
||||
|
||||
return args;
|
||||
return args
|
||||
}
|
||||
|
||||
private getAddAssetArguments(settings: GitReleaseManagerAddAssetSettings): string[] {
|
||||
const args: string[] = ['addasset', ...this.getCommonArguments(settings)];
|
||||
private getAddAssetArguments(
|
||||
settings: GitReleaseManagerAddAssetSettings
|
||||
): string[] {
|
||||
const args: string[] = [
|
||||
'addasset',
|
||||
...this.getCommonArguments(settings)
|
||||
]
|
||||
|
||||
if (settings.tagName) {
|
||||
args.push("--tagName", settings.tagName);
|
||||
args.push('--tagName', settings.tagName)
|
||||
}
|
||||
if (settings.assets && settings.assets.length > 0) {
|
||||
settings.assets = settings.assets.map(asset => {
|
||||
return path.join(settings.targetDirectory, asset)
|
||||
})
|
||||
|
||||
args.push("--assets", settings.assets.join(","));
|
||||
args.push('--assets', settings.assets.join(','))
|
||||
}
|
||||
|
||||
return args;
|
||||
return args
|
||||
}
|
||||
|
||||
private getRepoDir(targetPath: string): string {
|
||||
let workDir: string;
|
||||
const srcDir = this.buildAgent.getSourceDir();
|
||||
let workDir: string
|
||||
const srcDir = this.buildAgent.getSourceDir()
|
||||
if (!targetPath) {
|
||||
workDir = srcDir;
|
||||
workDir = srcDir
|
||||
} else {
|
||||
if (this.buildAgent.directoryExists(targetPath)) {
|
||||
workDir = path.join(srcDir, targetPath);
|
||||
workDir = path.join(srcDir, targetPath)
|
||||
} else {
|
||||
throw new Error("Directory not found at " + targetPath);
|
||||
throw new Error('Directory not found at ' + targetPath)
|
||||
}
|
||||
}
|
||||
return workDir.replace(/\\/g, "/");
|
||||
return workDir.replace(/\\/g, '/')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
export enum ExecuteFields {
|
||||
targetPath = "targetPath",
|
||||
useConfigFile = "useConfigFile",
|
||||
configFilePath = "configFilePath",
|
||||
updateAssemblyInfo = "updateAssemblyInfo",
|
||||
updateAssemblyInfoFilename = "updateAssemblyInfoFilename",
|
||||
additionalArguments = "additionalArguments",
|
||||
srcDir = "srcDir",
|
||||
};
|
||||
targetPath = 'targetPath',
|
||||
useConfigFile = 'useConfigFile',
|
||||
configFilePath = 'configFilePath',
|
||||
updateAssemblyInfo = 'updateAssemblyInfo',
|
||||
updateAssemblyInfoFilename = 'updateAssemblyInfoFilename',
|
||||
additionalArguments = 'additionalArguments',
|
||||
srcDir = 'srcDir'
|
||||
}
|
||||
|
||||
export interface GitVersionSettings {
|
||||
[ExecuteFields.targetPath]: string;
|
||||
[ExecuteFields.useConfigFile]: boolean;
|
||||
[ExecuteFields.configFilePath]: string;
|
||||
[ExecuteFields.updateAssemblyInfo]: boolean;
|
||||
[ExecuteFields.updateAssemblyInfoFilename]: string;
|
||||
[ExecuteFields.additionalArguments]: string;
|
||||
[ExecuteFields.srcDir]: string;
|
||||
[ExecuteFields.targetPath]: string
|
||||
[ExecuteFields.useConfigFile]: boolean
|
||||
[ExecuteFields.configFilePath]: string
|
||||
[ExecuteFields.updateAssemblyInfo]: boolean
|
||||
[ExecuteFields.updateAssemblyInfoFilename]: string
|
||||
[ExecuteFields.additionalArguments]: string
|
||||
[ExecuteFields.srcDir]: string
|
||||
}
|
||||
|
||||
export interface GitVersionOutput {
|
||||
Major: number;
|
||||
Minor: number;
|
||||
Patch: number;
|
||||
PreReleaseTag: string;
|
||||
PreReleaseTagWithDash: string;
|
||||
PreReleaseLabel: string;
|
||||
PreReleaseNumber: number;
|
||||
WeightedPreReleaseNumber: number;
|
||||
BuildMetaData: number;
|
||||
BuildMetaDataPadded: string;
|
||||
FullBuildMetaData: string;
|
||||
MajorMinorPatch: string;
|
||||
SemVer: string;
|
||||
LegacySemVer: string;
|
||||
LegacySemVerPadded: string;
|
||||
AssemblySemVer: string;
|
||||
AssemblySemFileVer: string;
|
||||
FullSemVer: string;
|
||||
InformationalVersion: string;
|
||||
BranchName: string;
|
||||
Sha: string;
|
||||
ShortSha: string;
|
||||
NuGetVersionV2: string;
|
||||
NuGetVersion: string;
|
||||
NuGetPreReleaseTagV2: string;
|
||||
NuGetPreReleaseTag: string;
|
||||
VersionSourceSha: string;
|
||||
CommitsSinceVersionSource: number;
|
||||
CommitsSinceVersionSourcePadded: string;
|
||||
CommitDate: string;
|
||||
Major: number
|
||||
Minor: number
|
||||
Patch: number
|
||||
PreReleaseTag: string
|
||||
PreReleaseTagWithDash: string
|
||||
PreReleaseLabel: string
|
||||
PreReleaseNumber: number
|
||||
WeightedPreReleaseNumber: number
|
||||
BuildMetaData: number
|
||||
BuildMetaDataPadded: string
|
||||
FullBuildMetaData: string
|
||||
MajorMinorPatch: string
|
||||
SemVer: string
|
||||
LegacySemVer: string
|
||||
LegacySemVerPadded: string
|
||||
AssemblySemVer: string
|
||||
AssemblySemFileVer: string
|
||||
FullSemVer: string
|
||||
InformationalVersion: string
|
||||
BranchName: string
|
||||
Sha: string
|
||||
ShortSha: string
|
||||
NuGetVersionV2: string
|
||||
NuGetVersion: string
|
||||
NuGetPreReleaseTagV2: string
|
||||
NuGetPreReleaseTag: string
|
||||
VersionSourceSha: string
|
||||
CommitsSinceVersionSource: number
|
||||
CommitsSinceVersionSourcePadded: string
|
||||
CommitDate: string
|
||||
}
|
||||
|
||||
@@ -1,21 +1,30 @@
|
||||
import { IBuildAgent } from "../../core/models";
|
||||
import {IBuildAgent} from '../../core/models'
|
||||
|
||||
import { GitVersionSettings, ExecuteFields } from "./models";
|
||||
import {GitVersionSettings, ExecuteFields} from './models'
|
||||
|
||||
export class Settings {
|
||||
public static getGitVersionSettings(
|
||||
buildAgent: IBuildAgent
|
||||
): GitVersionSettings {
|
||||
const targetPath = buildAgent.getInput(ExecuteFields.targetPath)
|
||||
|
||||
public static getGitVersionSettings(buildAgent: IBuildAgent): GitVersionSettings {
|
||||
const targetPath = buildAgent.getInput(ExecuteFields.targetPath);
|
||||
const useConfigFile = buildAgent.getBooleanInput(
|
||||
ExecuteFields.useConfigFile
|
||||
)
|
||||
const configFilePath = buildAgent.getInput(ExecuteFields.configFilePath)
|
||||
|
||||
const useConfigFile = buildAgent.getBooleanInput(ExecuteFields.useConfigFile);
|
||||
const configFilePath = buildAgent.getInput(ExecuteFields.configFilePath);
|
||||
const updateAssemblyInfo = buildAgent.getBooleanInput(
|
||||
ExecuteFields.updateAssemblyInfo
|
||||
)
|
||||
const updateAssemblyInfoFilename = buildAgent.getInput(
|
||||
ExecuteFields.updateAssemblyInfoFilename
|
||||
)
|
||||
|
||||
const updateAssemblyInfo = buildAgent.getBooleanInput(ExecuteFields.updateAssemblyInfo);
|
||||
const updateAssemblyInfoFilename = buildAgent.getInput(ExecuteFields.updateAssemblyInfoFilename);
|
||||
const additionalArguments = buildAgent.getInput(
|
||||
ExecuteFields.additionalArguments
|
||||
)
|
||||
|
||||
const additionalArguments = buildAgent.getInput(ExecuteFields.additionalArguments);
|
||||
|
||||
const srcDir = buildAgent.getSourceDir().replace(/\\/g, "/");
|
||||
const srcDir = buildAgent.getSourceDir().replace(/\\/g, '/')
|
||||
|
||||
return {
|
||||
targetPath,
|
||||
@@ -24,7 +33,7 @@ export class Settings {
|
||||
updateAssemblyInfo,
|
||||
updateAssemblyInfoFilename,
|
||||
additionalArguments,
|
||||
srcDir,
|
||||
};
|
||||
srcDir
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,120 +1,183 @@
|
||||
import path = require("path");
|
||||
import path = require('path')
|
||||
|
||||
import { injectable, inject } from "inversify";
|
||||
import { IExecResult, IBuildAgent, TYPES } from "../../core/models";
|
||||
import { DotnetTool, IDotnetTool } from "../../core/dotnet-tool";
|
||||
import { GitVersionSettings, GitVersionOutput, ExecuteFields } from "./models";
|
||||
import { IVersionManager } from "../../core/versionManager";
|
||||
import {injectable, inject} from 'inversify'
|
||||
import {IExecResult, IBuildAgent, TYPES} from '../../core/models'
|
||||
import {DotnetTool, IDotnetTool} from '../../core/dotnet-tool'
|
||||
import {GitVersionSettings, GitVersionOutput, ExecuteFields} from './models'
|
||||
import {IVersionManager} from '../../core/versionManager'
|
||||
|
||||
export interface IGitVersionTool extends IDotnetTool {
|
||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>;
|
||||
run(options: GitVersionSettings): Promise<IExecResult>;
|
||||
writeGitVersionToAgent(gitversion: GitVersionOutput): void;
|
||||
install(versionSpec: string, includePrerelease: boolean): Promise<void>
|
||||
run(options: GitVersionSettings): Promise<IExecResult>
|
||||
writeGitVersionToAgent(gitversion: GitVersionOutput): void
|
||||
}
|
||||
|
||||
@injectable()
|
||||
export class GitVersionTool extends DotnetTool implements IGitVersionTool {
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.IBuildAgent) buildAgent: IBuildAgent,
|
||||
@inject(TYPES.IVersionManager) versionManager: IVersionManager
|
||||
) {
|
||||
super(buildAgent, versionManager);
|
||||
super(buildAgent, versionManager)
|
||||
}
|
||||
|
||||
public async install(versionSpec: string, includePrerelease: boolean): Promise<void> {
|
||||
await this.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease);
|
||||
public async install(
|
||||
versionSpec: string,
|
||||
includePrerelease: boolean
|
||||
): Promise<void> {
|
||||
await this.toolInstall(
|
||||
'GitVersion.Tool',
|
||||
versionSpec,
|
||||
false,
|
||||
includePrerelease
|
||||
)
|
||||
}
|
||||
|
||||
public run(options: GitVersionSettings): Promise<IExecResult> {
|
||||
const workDir = this.getRepoDir(options.targetPath);
|
||||
const workDir = this.getRepoDir(options.targetPath)
|
||||
|
||||
const args = this.getArguments(workDir, options);
|
||||
const args = this.getArguments(workDir, options)
|
||||
|
||||
return this.execute("dotnet-gitversion", args);
|
||||
return this.execute('dotnet-gitversion', args)
|
||||
}
|
||||
|
||||
private getRepoDir(targetPath: string): string {
|
||||
let workDir: string;
|
||||
const srcDir = this.buildAgent.getSourceDir();
|
||||
let workDir: string
|
||||
const srcDir = this.buildAgent.getSourceDir()
|
||||
if (!targetPath) {
|
||||
workDir = srcDir;
|
||||
workDir = srcDir
|
||||
} else {
|
||||
if (this.buildAgent.directoryExists(targetPath)) {
|
||||
workDir = path.join(srcDir, targetPath);
|
||||
workDir = path.join(srcDir, targetPath)
|
||||
} else {
|
||||
throw new Error("Directory not found at " + targetPath);
|
||||
throw new Error('Directory not found at ' + targetPath)
|
||||
}
|
||||
}
|
||||
return workDir.replace(/\\/g, "/");
|
||||
return workDir.replace(/\\/g, '/')
|
||||
}
|
||||
|
||||
private getArguments(workDir: string, options: GitVersionSettings): string[] {
|
||||
const args = [
|
||||
workDir,
|
||||
"/output", "json",
|
||||
"/output", "buildserver",
|
||||
];
|
||||
private getArguments(
|
||||
workDir: string,
|
||||
options: GitVersionSettings
|
||||
): string[] {
|
||||
const args = [workDir, '/output', 'json', '/output', 'buildserver']
|
||||
|
||||
const {
|
||||
useConfigFile,
|
||||
configFilePath,
|
||||
updateAssemblyInfo,
|
||||
updateAssemblyInfoFilename,
|
||||
additionalArguments,
|
||||
} = options;
|
||||
additionalArguments
|
||||
} = options
|
||||
|
||||
if (useConfigFile) {
|
||||
if (this.buildAgent.isValidInputFile("configFilePath", configFilePath)) {
|
||||
args.push("/config", configFilePath);
|
||||
if (
|
||||
this.buildAgent.isValidInputFile(
|
||||
'configFilePath',
|
||||
configFilePath
|
||||
)
|
||||
) {
|
||||
args.push('/config', configFilePath)
|
||||
} else {
|
||||
throw new Error("GitVersion configuration file not found at " + configFilePath);
|
||||
throw new Error(
|
||||
'GitVersion configuration file not found at ' +
|
||||
configFilePath
|
||||
)
|
||||
}
|
||||
}
|
||||
if (updateAssemblyInfo) {
|
||||
args.push("/updateassemblyinfo");
|
||||
if (this.buildAgent.isValidInputFile("updateAssemblyInfoFilename", updateAssemblyInfoFilename)) {
|
||||
args.push(updateAssemblyInfoFilename);
|
||||
args.push('/updateassemblyinfo')
|
||||
if (
|
||||
this.buildAgent.isValidInputFile(
|
||||
'updateAssemblyInfoFilename',
|
||||
updateAssemblyInfoFilename
|
||||
)
|
||||
) {
|
||||
args.push(updateAssemblyInfoFilename)
|
||||
} else {
|
||||
throw new Error("AssemblyInfoFilename file not found at " + updateAssemblyInfoFilename);
|
||||
throw new Error(
|
||||
'AssemblyInfoFilename file not found at ' +
|
||||
updateAssemblyInfoFilename
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
args.push(additionalArguments);
|
||||
return args;
|
||||
args.push(additionalArguments)
|
||||
return args
|
||||
}
|
||||
|
||||
public writeGitVersionToAgent(gitversion: GitVersionOutput): void {
|
||||
|
||||
this.buildAgent.setOutput("major", gitversion.Major.toString());
|
||||
this.buildAgent.setOutput("minor", gitversion.Minor.toString());
|
||||
this.buildAgent.setOutput("patch", gitversion.Patch.toString());
|
||||
this.buildAgent.setOutput("preReleaseTag", gitversion.PreReleaseTag);
|
||||
this.buildAgent.setOutput("preReleaseTagWithDash", gitversion.PreReleaseTagWithDash);
|
||||
this.buildAgent.setOutput("preReleaseLabel", gitversion.PreReleaseLabel);
|
||||
this.buildAgent.setOutput("preReleaseNumber", gitversion.PreReleaseNumber.toString());
|
||||
this.buildAgent.setOutput("weightedPreReleaseNumber", gitversion.WeightedPreReleaseNumber.toString());
|
||||
this.buildAgent.setOutput("buildMetaData", gitversion.BuildMetaData.toString());
|
||||
this.buildAgent.setOutput("buildMetaDataPadded", gitversion.BuildMetaDataPadded);
|
||||
this.buildAgent.setOutput("fullBuildMetaData", gitversion.FullBuildMetaData);
|
||||
this.buildAgent.setOutput("majorMinorPatch", gitversion.MajorMinorPatch);
|
||||
this.buildAgent.setOutput("semVer", gitversion.SemVer);
|
||||
this.buildAgent.setOutput("legacySemVer", gitversion.LegacySemVer);
|
||||
this.buildAgent.setOutput("legacySemVerPadded", gitversion.LegacySemVerPadded);
|
||||
this.buildAgent.setOutput("assemblySemVer", gitversion.AssemblySemVer);
|
||||
this.buildAgent.setOutput("assemblySemFileVer", gitversion.AssemblySemFileVer);
|
||||
this.buildAgent.setOutput("fullSemVer", gitversion.FullSemVer);
|
||||
this.buildAgent.setOutput("informationalVersion", gitversion.InformationalVersion);
|
||||
this.buildAgent.setOutput("branchName", gitversion.BranchName);
|
||||
this.buildAgent.setOutput("sha", gitversion.Sha);
|
||||
this.buildAgent.setOutput("shortSha", gitversion.ShortSha);
|
||||
this.buildAgent.setOutput("nuGetVersionV2", gitversion.NuGetVersionV2);
|
||||
this.buildAgent.setOutput("nuGetVersion", gitversion.NuGetVersion);
|
||||
this.buildAgent.setOutput("nuGetPreReleaseTagV2", gitversion.NuGetPreReleaseTagV2);
|
||||
this.buildAgent.setOutput("nuGetPreReleaseTag", gitversion.NuGetPreReleaseTag);
|
||||
this.buildAgent.setOutput("versionSourceSha", gitversion.VersionSourceSha);
|
||||
this.buildAgent.setOutput("commitsSinceVersionSource", gitversion.CommitsSinceVersionSource.toString());
|
||||
this.buildAgent.setOutput("commitsSinceVersionSourcePadded", gitversion.CommitsSinceVersionSourcePadded);
|
||||
this.buildAgent.setOutput("commitDate", gitversion.CommitDate);
|
||||
this.buildAgent.setOutput('major', gitversion.Major.toString())
|
||||
this.buildAgent.setOutput('minor', gitversion.Minor.toString())
|
||||
this.buildAgent.setOutput('patch', gitversion.Patch.toString())
|
||||
this.buildAgent.setOutput('preReleaseTag', gitversion.PreReleaseTag)
|
||||
this.buildAgent.setOutput(
|
||||
'preReleaseTagWithDash',
|
||||
gitversion.PreReleaseTagWithDash
|
||||
)
|
||||
this.buildAgent.setOutput('preReleaseLabel', gitversion.PreReleaseLabel)
|
||||
this.buildAgent.setOutput(
|
||||
'preReleaseNumber',
|
||||
gitversion.PreReleaseNumber.toString()
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'weightedPreReleaseNumber',
|
||||
gitversion.WeightedPreReleaseNumber.toString()
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'buildMetaData',
|
||||
gitversion.BuildMetaData.toString()
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'buildMetaDataPadded',
|
||||
gitversion.BuildMetaDataPadded
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'fullBuildMetaData',
|
||||
gitversion.FullBuildMetaData
|
||||
)
|
||||
this.buildAgent.setOutput('majorMinorPatch', gitversion.MajorMinorPatch)
|
||||
this.buildAgent.setOutput('semVer', gitversion.SemVer)
|
||||
this.buildAgent.setOutput('legacySemVer', gitversion.LegacySemVer)
|
||||
this.buildAgent.setOutput(
|
||||
'legacySemVerPadded',
|
||||
gitversion.LegacySemVerPadded
|
||||
)
|
||||
this.buildAgent.setOutput('assemblySemVer', gitversion.AssemblySemVer)
|
||||
this.buildAgent.setOutput(
|
||||
'assemblySemFileVer',
|
||||
gitversion.AssemblySemFileVer
|
||||
)
|
||||
this.buildAgent.setOutput('fullSemVer', gitversion.FullSemVer)
|
||||
this.buildAgent.setOutput(
|
||||
'informationalVersion',
|
||||
gitversion.InformationalVersion
|
||||
)
|
||||
this.buildAgent.setOutput('branchName', gitversion.BranchName)
|
||||
this.buildAgent.setOutput('sha', gitversion.Sha)
|
||||
this.buildAgent.setOutput('shortSha', gitversion.ShortSha)
|
||||
this.buildAgent.setOutput('nuGetVersionV2', gitversion.NuGetVersionV2)
|
||||
this.buildAgent.setOutput('nuGetVersion', gitversion.NuGetVersion)
|
||||
this.buildAgent.setOutput(
|
||||
'nuGetPreReleaseTagV2',
|
||||
gitversion.NuGetPreReleaseTagV2
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'nuGetPreReleaseTag',
|
||||
gitversion.NuGetPreReleaseTag
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'versionSourceSha',
|
||||
gitversion.VersionSourceSha
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'commitsSinceVersionSource',
|
||||
gitversion.CommitsSinceVersionSource.toString()
|
||||
)
|
||||
this.buildAgent.setOutput(
|
||||
'commitsSinceVersionSourcePadded',
|
||||
gitversion.CommitsSinceVersionSourcePadded
|
||||
)
|
||||
this.buildAgent.setOutput('commitDate', gitversion.CommitDate)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user