Add '--ignore-failed-sources' to options

This commit is contained in:
matteopey
2022-03-16 23:47:41 +01:00
committed by Artur
parent a7350ecf47
commit c6c07deac4
9 changed files with 60 additions and 41 deletions

View File

@@ -36,6 +36,14 @@
"defaultValue": "false",
"required": false,
"helpMarkDown": "Include pre-release versions when matching a version"
},
{
"name": "ignoreFailedSources",
"type": "boolean",
"label": "Treat package source failures as warnings",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Treat package source failures as warnings"
}
]
}

View File

@@ -36,6 +36,14 @@
"defaultValue": "false",
"required": false,
"helpMarkDown": "Include pre-release versions when matching a version"
},
{
"name": "ignoreFailedSources",
"type": "boolean",
"label": "Treat package source failures as warnings",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Treat package source failures as warnings"
}
]
}

View File

@@ -4,16 +4,15 @@ 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 { TYPES, IExecResult, IBuildAgent, ISetupSettings } from './models'
import { IVersionManager } from './versionManager'
export interface IDotnetTool {
disableTelemetry(): void
toolInstall(
toolName: string,
versionSpec: string,
checkLatest: boolean,
includePre: boolean
setupSettings: ISetupSettings
): Promise<string>
}
@@ -51,16 +50,17 @@ export class DotnetTool implements IDotnetTool {
public async toolInstall(
toolName: string,
versionSpec: string,
checkLatest: boolean,
includePre: boolean
setupSettings: ISetupSettings
): Promise<string> {
console.log('')
console.log('--------------------------')
console.log(`Installing ${toolName} version ` + versionSpec)
console.log(
`Installing ${toolName} version ` + setupSettings.versionSpec
)
console.log('--------------------------')
if (this.versionManager.isExplicitVersion(versionSpec)) {
if (this.versionManager.isExplicitVersion(setupSettings.versionSpec)) {
checkLatest = false // check latest doesn't make sense when explicit version
}
@@ -69,16 +69,18 @@ export class DotnetTool implements IDotnetTool {
//
// Let's try and resolve the version spec locally first
//
toolPath = this.buildAgent.find(toolName, versionSpec)
toolPath = this.buildAgent.find(toolName, setupSettings.versionSpec)
}
if (!toolPath) {
let version: string
if (this.versionManager.isExplicitVersion(versionSpec)) {
if (
this.versionManager.isExplicitVersion(setupSettings.versionSpec)
) {
//
// Explicit version was specified. No need to query for list of versions.
//
version = versionSpec
version = setupSettings.versionSpec
} else {
//
// Let's query and resolve the latest version for the versionSpec.
@@ -88,12 +90,12 @@ export class DotnetTool implements IDotnetTool {
//
version = await this.queryLatestMatch(
toolName,
versionSpec,
includePre
setupSettings.versionSpec,
setupSettings.includePrerelease
)
if (!version) {
throw new Error(
`Unable to find ${toolName} version '${versionSpec}'.`
`Unable to find ${toolName} version '${setupSettings.versionSpec}'.`
)
}
@@ -106,7 +108,11 @@ export class DotnetTool implements IDotnetTool {
//
// Download, extract, cache
//
toolPath = await this.acquireTool(toolName, version)
toolPath = await this.acquireTool(
toolName,
version,
setupSettings.ignoreFailedSources
)
}
}
@@ -170,11 +176,16 @@ export class DotnetTool implements IDotnetTool {
private async acquireTool(
toolName: string,
version: string
version: string,
ignoreFailedSources: boolean
): Promise<string> {
const tempDirectory = await this.buildAgent.createTempDir()
let args = ['tool', 'install', toolName, '--tool-path', tempDirectory]
if (ignoreFailedSources) {
args.push('--ignore-failed-sources')
}
if (version) {
version = this.versionManager.cleanVersion(version)
args = args.concat(['--version', version])

View File

@@ -10,12 +10,14 @@ export const TYPES = {
export enum SetupFields {
includePrerelease = 'includePrerelease',
versionSpec = 'versionSpec'
versionSpec = 'versionSpec',
ignoreFailedSources = 'ignoreFailedSources'
}
export interface ISetupSettings {
[SetupFields.versionSpec]: string
[SetupFields.includePrerelease]: boolean
[SetupFields.ignoreFailedSources]: boolean
}
export interface IExecResult {

View File

@@ -6,10 +6,14 @@ export class Settings {
const includePrerelease = buildAgent.getBooleanInput(
SetupFields.includePrerelease
)
const ignoreFailedSources = buildAgent.getBooleanInput(
SetupFields.ignoreFailedSources
)
return {
versionSpec,
includePrerelease
includePrerelease,
ignoreFailedSources
}
}
}

View File

@@ -23,10 +23,7 @@ export async function setup() {
const settings = CommonSettings.getSetupSettings(buildAgent)
await gitReleaseManagerTool.install(
settings.versionSpec,
settings.includePrerelease
)
await gitReleaseManagerTool.install(settings)
buildAgent.setSucceeded(
'GitVersionManager installed successfully',

View File

@@ -20,10 +20,7 @@ export async function setup() {
const settings = CommonSettings.getSetupSettings(buildAgent)
await gitVersionTool.install(
settings.versionSpec,
settings.includePrerelease
)
await gitVersionTool.install(settings)
buildAgent.setSucceeded('GitVersion installed successfully', true)
} catch (error) {

View File

@@ -1,6 +1,6 @@
import path = require('path')
import { TYPES, IBuildAgent, IExecResult } from '../../core/models'
import { TYPES, IBuildAgent, IExecResult, ISetupSettings } from '../../core/models'
import { injectable, inject } from 'inversify'
import { DotnetTool, IDotnetTool } from '../../core/dotnet-tool'
import { IVersionManager } from '../../core/versionManager'
@@ -16,7 +16,7 @@ import {
} from './models'
export interface IGitReleaseManagerTool extends IDotnetTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>
install(setupSettings: ISetupSettings): Promise<void>
create(settings: GitReleaseManagerCreateSettings): Promise<IExecResult>
discard(settings: GitReleaseManagerDiscardSettings): Promise<IExecResult>
close(settings: GitReleaseManagerCloseSettings): Promise<IExecResult>
@@ -36,15 +36,11 @@ export class GitReleaseManagerTool
super(buildAgent, versionManager)
}
public async install(
versionSpec: string,
includePrerelease: boolean
): Promise<void> {
public async install(setupSettings: ISetupSettings): Promise<void> {
await this.toolInstall(
'GitReleaseManager.Tool',
versionSpec,
false,
includePrerelease
setupSettings
)
}

View File

@@ -1,13 +1,13 @@
import path = require('path')
import { injectable, inject } from 'inversify'
import { IExecResult, IBuildAgent, TYPES } from '../../core/models'
import { IExecResult, IBuildAgent, TYPES, ISetupSettings } from '../../core/models'
import { DotnetTool, IDotnetTool } from '../../core/dotnet-tool'
import { GitVersionSettings, GitVersionOutput } from './models'
import { IVersionManager } from '../../core/versionManager'
export interface IGitVersionTool extends IDotnetTool {
install(versionSpec: string, includePrerelease: boolean): Promise<void>
install(setupSettings: ISetupSettings): Promise<void>
run(options: GitVersionSettings): Promise<IExecResult>
writeGitVersionToAgent(gitversion: GitVersionOutput): void
}
@@ -21,15 +21,11 @@ export class GitVersionTool extends DotnetTool implements IGitVersionTool {
super(buildAgent, versionManager)
}
public async install(
versionSpec: string,
includePrerelease: boolean
): Promise<void> {
public async install(setupSettings: ISetupSettings): Promise<void> {
await this.toolInstall(
'GitVersion.Tool',
versionSpec,
false,
includePrerelease
setupSettings
)
}