From 7ebd94ca8d2c45acbf480fe9a4d23b8556d5aaf5 Mon Sep 17 00:00:00 2001 From: Elliot Nelson Date: Thu, 25 Feb 2021 09:46:19 -0500 Subject: [PATCH 1/2] Allow user-specified override parameters ref and sha - Specify optional `ref:` parameter to override GITHUB_REF - Specify optional `sha:` parameter to override GITHUB_SHA --- action.yml | 31 +-- lib/main.js | 72 +++---- lib/pipeline.error.js | 20 +- lib/pipeline.runner.js | 371 +++++++++++++++++++----------------- lib/task.parameters.js | 74 +++---- lib/util/logger.js | 74 +++---- lib/util/pipeline.helper.js | 184 +++++++++--------- lib/util/url.parser.js | 120 ++++++------ src/pipeline.runner.ts | 16 +- src/task.parameters.ts | 14 +- 10 files changed, 513 insertions(+), 463 deletions(-) diff --git a/action.yml b/action.yml index 780b36b1..4326e587 100644 --- a/action.yml +++ b/action.yml @@ -1,15 +1,22 @@ -name: 'Azure Pipelines Action' -description: 'Trigger a run in Azure pipelines' +name: 'Azure Pipelines Action' +description: 'Trigger a run in Azure pipelines' inputs: azure-devops-project-url: - description: 'Fullyqualified URL to the Azure DevOps organization along with project name(eg, https://dev.azure.com/organization/project-name or https://server.example.com:8080/tfs/DefaultCollection/project-name)' - required: true + description: 'Fullyqualified URL to the Azure DevOps organization along with project name(eg, https://dev.azure.com/organization/project-name or https://server.example.com:8080/tfs/DefaultCollection/project-name)' + required: true azure-pipeline-name: - description: 'Name of the Azure Pipline to be triggered' - required: true - azure-devops-token: - description: 'Paste personal access token of the user as value of secret variable:AZURE_DEVOPS_TOKEN' - required: true -runs: - using: 'node12' - main: 'lib/main.js' \ No newline at end of file + description: 'Name of the Azure Pipline to be triggered' + required: true + azure-devops-token: + description: 'Paste personal access token of the user as value of secret variable:AZURE_DEVOPS_TOKEN' + required: true + ref: + description: 'Specify to override the default ref ($GITHUB_REF)' + required: false + sha: + description: 'Specify to override the default sha ($GITHUB_SHA)' + required: false + +runs: + using: 'node12' + main: 'lib/main.js' diff --git a/lib/main.js b/lib/main.js index c93b89bd..bd82164e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,36 +1,36 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -const task_parameters_1 = require("./task.parameters"); -const pipeline_runner_1 = require("./pipeline.runner"); -function main() { - return __awaiter(this, void 0, void 0, function* () { - try { - const pipelineRunner = new pipeline_runner_1.PipelineRunner(task_parameters_1.TaskParameters.getTaskParams()); - core.debug("Starting pipeline runner"); - yield pipelineRunner.start(); - core.debug("pipeline runner completed"); - } - catch (error) { - const errorMessage = JSON.stringify(error); - core.setFailed(`Error: "${error.message}" Details: "${errorMessage}"`); - } - }); -} -main(); +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(require("@actions/core")); +const task_parameters_1 = require("./task.parameters"); +const pipeline_runner_1 = require("./pipeline.runner"); +function main() { + return __awaiter(this, void 0, void 0, function* () { + try { + const pipelineRunner = new pipeline_runner_1.PipelineRunner(task_parameters_1.TaskParameters.getTaskParams()); + core.debug("Starting pipeline runner"); + yield pipelineRunner.start(); + core.debug("pipeline runner completed"); + } + catch (error) { + const errorMessage = JSON.stringify(error); + core.setFailed(`Error: "${error.message}" Details: "${errorMessage}"`); + } + }); +} +main(); diff --git a/lib/pipeline.error.js b/lib/pipeline.error.js index 25935ff3..86fb406e 100644 --- a/lib/pipeline.error.js +++ b/lib/pipeline.error.js @@ -1,10 +1,10 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class PipelineNotFoundError extends Error { - constructor(m) { - super(m); - // Required to allow use of "instanceof" - Object.setPrototypeOf(this, PipelineNotFoundError.prototype); - } -} -exports.PipelineNotFoundError = PipelineNotFoundError; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +class PipelineNotFoundError extends Error { + constructor(m) { + super(m); + // Required to allow use of "instanceof" + Object.setPrototypeOf(this, PipelineNotFoundError.prototype); + } +} +exports.PipelineNotFoundError = PipelineNotFoundError; diff --git a/lib/pipeline.runner.js b/lib/pipeline.runner.js index 6d84a18f..e6fed5ae 100644 --- a/lib/pipeline.runner.js +++ b/lib/pipeline.runner.js @@ -1,180 +1,191 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -const azdev = __importStar(require("azure-devops-node-api")); -const task_parameters_1 = require("./task.parameters"); -const pipeline_error_1 = require("./pipeline.error"); -const ReleaseInterfaces = __importStar(require("azure-devops-node-api/interfaces/ReleaseInterfaces")); -const BuildInterfaces = __importStar(require("azure-devops-node-api/interfaces/BuildInterfaces")); -const pipeline_helper_1 = require("./util/pipeline.helper"); -const logger_1 = require("./util/logger"); -const url_parser_1 = require("./util/url.parser"); -class PipelineRunner { - constructor(taskParameters) { - this.repository = pipeline_helper_1.PipelineHelper.processEnv("GITHUB_REPOSITORY"); - this.branch = pipeline_helper_1.PipelineHelper.processEnv("GITHUB_REF"); - this.commitId = pipeline_helper_1.PipelineHelper.processEnv("GITHUB_SHA"); - this.githubRepo = "GitHub"; - this.taskParameters = taskParameters; - } - start() { - return __awaiter(this, void 0, void 0, function* () { - try { - var taskParams = task_parameters_1.TaskParameters.getTaskParams(); - let authHandler = azdev.getPersonalAccessTokenHandler(taskParams.azureDevopsToken); - let collectionUrl = url_parser_1.UrlParser.GetCollectionUrlBase(this.taskParameters.azureDevopsProjectUrl); - core.info(`Creating connection with Azure DevOps service : "${collectionUrl}"`); - let webApi = new azdev.WebApi(collectionUrl, authHandler); - core.info("Connection created"); - let pipelineName = this.taskParameters.azurePipelineName; - try { - core.debug(`Triggering Yaml pipeline : "${pipelineName}"`); - yield this.RunYamlPipeline(webApi); - } - catch (error) { - if (error instanceof pipeline_error_1.PipelineNotFoundError) { - core.debug(`Triggering Designer pipeline : "${pipelineName}"`); - yield this.RunDesignerPipeline(webApi); - } - else { - throw error; - } - } - } - catch (error) { - let errorMessage = `${error.message}`; - core.setFailed(errorMessage); - } - }); - } - RunYamlPipeline(webApi) { - return __awaiter(this, void 0, void 0, function* () { - let projectName = url_parser_1.UrlParser.GetProjectName(this.taskParameters.azureDevopsProjectUrl); - let pipelineName = this.taskParameters.azurePipelineName; - let buildApi = yield webApi.getBuildApi(); - // Get matching build definitions for the given project and pipeline name - const buildDefinitions = yield buildApi.getDefinitions(projectName, pipelineName); - pipeline_helper_1.PipelineHelper.EnsureValidPipeline(projectName, pipelineName, buildDefinitions); - // Extract Id from build definition - let buildDefinitionReference = buildDefinitions[0]; - let buildDefinitionId = buildDefinitionReference.id; - // Get build definition for the matching definition Id - let buildDefinition = yield buildApi.getDefinition(projectName, buildDefinitionId); - logger_1.Logger.LogPipelineObject(buildDefinition); - // Fetch repository details from build definition - let repositoryId = buildDefinition.repository.id.trim(); - let repositoryType = buildDefinition.repository.type.trim(); - let sourceBranch = null; - let sourceVersion = null; - // If definition is linked to existing github repo, pass github source branch and source version to build - if (pipeline_helper_1.PipelineHelper.equals(repositoryId, this.repository) && pipeline_helper_1.PipelineHelper.equals(repositoryType, this.githubRepo)) { - core.debug("pipeline is linked to same Github repo"); - sourceBranch = this.branch, - sourceVersion = this.commitId; - } - else { - core.debug("pipeline is not linked to same Github repo"); - } - let build = { - definition: { - id: buildDefinition.id - }, - project: { - id: buildDefinition.project.id - }, - sourceBranch: sourceBranch, - sourceVersion: sourceVersion, - reason: BuildInterfaces.BuildReason.Triggered - }; - logger_1.Logger.LogPipelineTriggerInput(build); - // Queue build - let buildQueueResult = yield buildApi.queueBuild(build, build.project.id, true); - if (buildQueueResult != null) { - logger_1.Logger.LogPipelineTriggerOutput(buildQueueResult); - // If build result contains validation errors set result to FAILED - if (buildQueueResult.validationResults != null && buildQueueResult.validationResults.length > 0) { - let errorAndWarningMessage = pipeline_helper_1.PipelineHelper.getErrorAndWarningMessageFromBuildResult(buildQueueResult.validationResults); - core.setFailed("Errors: " + errorAndWarningMessage.errorMessage + " Warnings: " + errorAndWarningMessage.warningMessage); - } - else { - logger_1.Logger.LogPipelineTriggered(pipelineName, projectName); - if (buildQueueResult._links != null) { - logger_1.Logger.LogOutputUrl(buildQueueResult._links.web.href); - } - } - } - }); - } - RunDesignerPipeline(webApi) { - return __awaiter(this, void 0, void 0, function* () { - let projectName = url_parser_1.UrlParser.GetProjectName(this.taskParameters.azureDevopsProjectUrl); - let pipelineName = this.taskParameters.azurePipelineName; - let releaseApi = yield webApi.getReleaseApi(); - // Get release definitions for the given project name and pipeline name - const releaseDefinitions = yield releaseApi.getReleaseDefinitions(projectName, pipelineName, ReleaseInterfaces.ReleaseDefinitionExpands.Artifacts); - pipeline_helper_1.PipelineHelper.EnsureValidPipeline(projectName, pipelineName, releaseDefinitions); - let releaseDefinition = releaseDefinitions[0]; - logger_1.Logger.LogPipelineObject(releaseDefinition); - // Filter Github artifacts from release definition - let gitHubArtifacts = releaseDefinition.artifacts.filter(pipeline_helper_1.PipelineHelper.isGitHubArtifact); - let artifacts = new Array(); - if (gitHubArtifacts == null || gitHubArtifacts.length == 0) { - core.debug("Pipeline is not linked to any GitHub artifact"); - // If no GitHub artifacts found it means pipeline is not linked to any GitHub artifact - } - else { - // If pipeline has any matching Github artifact - core.debug("Pipeline is linked to GitHub artifact. Looking for now matching repository"); - gitHubArtifacts.forEach(gitHubArtifact => { - if (gitHubArtifact.definitionReference != null && pipeline_helper_1.PipelineHelper.equals(gitHubArtifact.definitionReference.definition.name, this.repository)) { - // Add version information for matching GitHub artifact - let artifactMetadata = { - alias: gitHubArtifact.alias, - instanceReference: { - id: this.commitId, - sourceBranch: this.branch, - sourceRepositoryType: this.githubRepo, - sourceRepositoryId: this.repository, - sourceVersion: this.commitId - } - }; - core.debug("pipeline is linked to same Github repo"); - artifacts.push(artifactMetadata); - } - }); - } - let releaseStartMetadata = { - definitionId: releaseDefinition.id, - reason: ReleaseInterfaces.ReleaseReason.ContinuousIntegration, - artifacts: artifacts - }; - logger_1.Logger.LogPipelineTriggerInput(releaseStartMetadata); - // create release - let release = yield releaseApi.createRelease(releaseStartMetadata, projectName); - if (release != null) { - logger_1.Logger.LogPipelineTriggered(pipelineName, projectName); - logger_1.Logger.LogPipelineTriggerOutput(release); - if (release != null && release._links != null) { - logger_1.Logger.LogOutputUrl(release._links.web.href); - } - } - }); - } -} -exports.PipelineRunner = PipelineRunner; +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(require("@actions/core")); +const azdev = __importStar(require("azure-devops-node-api")); +const task_parameters_1 = require("./task.parameters"); +const pipeline_error_1 = require("./pipeline.error"); +const ReleaseInterfaces = __importStar(require("azure-devops-node-api/interfaces/ReleaseInterfaces")); +const BuildInterfaces = __importStar(require("azure-devops-node-api/interfaces/BuildInterfaces")); +const pipeline_helper_1 = require("./util/pipeline.helper"); +const logger_1 = require("./util/logger"); +const url_parser_1 = require("./util/url.parser"); +class PipelineRunner { + constructor(taskParameters) { + this.repository = pipeline_helper_1.PipelineHelper.processEnv("GITHUB_REPOSITORY"); + this.branch = pipeline_helper_1.PipelineHelper.processEnv("GITHUB_REF"); + this.commitId = pipeline_helper_1.PipelineHelper.processEnv("GITHUB_SHA"); + this.githubRepo = "GitHub"; + this.taskParameters = taskParameters; + } + start() { + return __awaiter(this, void 0, void 0, function* () { + try { + var taskParams = task_parameters_1.TaskParameters.getTaskParams(); + let authHandler = azdev.getPersonalAccessTokenHandler(taskParams.azureDevopsToken); + let collectionUrl = url_parser_1.UrlParser.GetCollectionUrlBase(this.taskParameters.azureDevopsProjectUrl); + core.info(`Creating connection with Azure DevOps service : "${collectionUrl}"`); + let webApi = new azdev.WebApi(collectionUrl, authHandler); + core.info("Connection created"); + let pipelineName = this.taskParameters.azurePipelineName; + try { + core.debug(`Triggering Yaml pipeline : "${pipelineName}"`); + yield this.RunYamlPipeline(webApi); + } + catch (error) { + if (error instanceof pipeline_error_1.PipelineNotFoundError) { + core.debug(`Triggering Designer pipeline : "${pipelineName}"`); + yield this.RunDesignerPipeline(webApi); + } + else { + throw error; + } + } + } + catch (error) { + let errorMessage = `${error.message}`; + core.setFailed(errorMessage); + } + }); + } + RunYamlPipeline(webApi) { + return __awaiter(this, void 0, void 0, function* () { + let projectName = url_parser_1.UrlParser.GetProjectName(this.taskParameters.azureDevopsProjectUrl); + let pipelineName = this.taskParameters.azurePipelineName; + let buildApi = yield webApi.getBuildApi(); + // Get matching build definitions for the given project and pipeline name + const buildDefinitions = yield buildApi.getDefinitions(projectName, pipelineName); + pipeline_helper_1.PipelineHelper.EnsureValidPipeline(projectName, pipelineName, buildDefinitions); + // Extract Id from build definition + let buildDefinitionReference = buildDefinitions[0]; + let buildDefinitionId = buildDefinitionReference.id; + // Get build definition for the matching definition Id + let buildDefinition = yield buildApi.getDefinition(projectName, buildDefinitionId); + logger_1.Logger.LogPipelineObject(buildDefinition); + // Fetch repository details from build definition + let repositoryId = buildDefinition.repository.id.trim(); + let repositoryType = buildDefinition.repository.type.trim(); + let sourceBranch = null; + let sourceVersion = null; + // If definition is linked to existing github repo, pass github source branch and source version to build + if (pipeline_helper_1.PipelineHelper.equals(repositoryId, this.repository) && pipeline_helper_1.PipelineHelper.equals(repositoryType, this.githubRepo)) { + core.debug("pipeline is linked to same Github repo"); + sourceBranch = this.branch, + sourceVersion = this.commitId; + } + else { + core.debug("pipeline is not linked to same Github repo"); + } + // If provided, the user-specified ref and sha override our implied branch + // and commit hash from GitHub. This is useful when we're using this action + // in workflows triggered by non-PR events (like issue_comment). + if (this.taskParameters.ref) { + sourceBranch = this.taskParameters.ref; + core.debug(`using user-specified ref ${sourceBranch}`); + } + if (this.taskParameters.sha) { + sourceVersion = this.taskParameters.sha; + core.debug(`using user-specified sha ${sourceVersion}`); + } + let build = { + definition: { + id: buildDefinition.id + }, + project: { + id: buildDefinition.project.id + }, + sourceBranch: sourceBranch, + sourceVersion: sourceVersion, + reason: BuildInterfaces.BuildReason.Triggered + }; + logger_1.Logger.LogPipelineTriggerInput(build); + // Queue build + let buildQueueResult = yield buildApi.queueBuild(build, build.project.id, true); + if (buildQueueResult != null) { + logger_1.Logger.LogPipelineTriggerOutput(buildQueueResult); + // If build result contains validation errors set result to FAILED + if (buildQueueResult.validationResults != null && buildQueueResult.validationResults.length > 0) { + let errorAndWarningMessage = pipeline_helper_1.PipelineHelper.getErrorAndWarningMessageFromBuildResult(buildQueueResult.validationResults); + core.setFailed("Errors: " + errorAndWarningMessage.errorMessage + " Warnings: " + errorAndWarningMessage.warningMessage); + } + else { + logger_1.Logger.LogPipelineTriggered(pipelineName, projectName); + if (buildQueueResult._links != null) { + logger_1.Logger.LogOutputUrl(buildQueueResult._links.web.href); + } + } + } + }); + } + RunDesignerPipeline(webApi) { + return __awaiter(this, void 0, void 0, function* () { + let projectName = url_parser_1.UrlParser.GetProjectName(this.taskParameters.azureDevopsProjectUrl); + let pipelineName = this.taskParameters.azurePipelineName; + let releaseApi = yield webApi.getReleaseApi(); + // Get release definitions for the given project name and pipeline name + const releaseDefinitions = yield releaseApi.getReleaseDefinitions(projectName, pipelineName, ReleaseInterfaces.ReleaseDefinitionExpands.Artifacts); + pipeline_helper_1.PipelineHelper.EnsureValidPipeline(projectName, pipelineName, releaseDefinitions); + let releaseDefinition = releaseDefinitions[0]; + logger_1.Logger.LogPipelineObject(releaseDefinition); + // Filter Github artifacts from release definition + let gitHubArtifacts = releaseDefinition.artifacts.filter(pipeline_helper_1.PipelineHelper.isGitHubArtifact); + let artifacts = new Array(); + if (gitHubArtifacts == null || gitHubArtifacts.length == 0) { + core.debug("Pipeline is not linked to any GitHub artifact"); + // If no GitHub artifacts found it means pipeline is not linked to any GitHub artifact + } + else { + // If pipeline has any matching Github artifact + core.debug("Pipeline is linked to GitHub artifact. Looking for now matching repository"); + gitHubArtifacts.forEach(gitHubArtifact => { + if (gitHubArtifact.definitionReference != null && pipeline_helper_1.PipelineHelper.equals(gitHubArtifact.definitionReference.definition.name, this.repository)) { + // Add version information for matching GitHub artifact + let artifactMetadata = { + alias: gitHubArtifact.alias, + instanceReference: { + id: this.commitId, + sourceBranch: this.branch, + sourceRepositoryType: this.githubRepo, + sourceRepositoryId: this.repository, + sourceVersion: this.commitId + } + }; + core.debug("pipeline is linked to same Github repo"); + artifacts.push(artifactMetadata); + } + }); + } + let releaseStartMetadata = { + definitionId: releaseDefinition.id, + reason: ReleaseInterfaces.ReleaseReason.ContinuousIntegration, + artifacts: artifacts + }; + logger_1.Logger.LogPipelineTriggerInput(releaseStartMetadata); + // create release + let release = yield releaseApi.createRelease(releaseStartMetadata, projectName); + if (release != null) { + logger_1.Logger.LogPipelineTriggered(pipelineName, projectName); + logger_1.Logger.LogPipelineTriggerOutput(release); + if (release != null && release._links != null) { + logger_1.Logger.LogOutputUrl(release._links.web.href); + } + } + }); + } +} +exports.PipelineRunner = PipelineRunner; diff --git a/lib/task.parameters.js b/lib/task.parameters.js index 44f00f9f..ea411087 100644 --- a/lib/task.parameters.js +++ b/lib/task.parameters.js @@ -1,33 +1,41 @@ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -class TaskParameters { - constructor() { - this._azureDevopsProjectUrl = core.getInput('azure-devops-project-url', { required: true }); - this._azurePipelineName = core.getInput('azure-pipeline-name', { required: true }); - this._azureDevopsToken = core.getInput('azure-devops-token', { required: true }); - } - static getTaskParams() { - if (!this.taskparams) { - this.taskparams = new TaskParameters(); - } - return this.taskparams; - } - get azureDevopsProjectUrl() { - return this._azureDevopsProjectUrl; - } - get azurePipelineName() { - return this._azurePipelineName; - } - get azureDevopsToken() { - return this._azureDevopsToken; - } -} -exports.TaskParameters = TaskParameters; +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(require("@actions/core")); +class TaskParameters { + constructor() { + this._azureDevopsProjectUrl = core.getInput('azure-devops-project-url', { required: true }); + this._azurePipelineName = core.getInput('azure-pipeline-name', { required: true }); + this._azureDevopsToken = core.getInput('azure-devops-token', { required: true }); + this._ref = core.getInput('ref', { required: false }); + this._sha = core.getInput('sha', { required: false }); + } + static getTaskParams() { + if (!this.taskparams) { + this.taskparams = new TaskParameters(); + } + return this.taskparams; + } + get azureDevopsProjectUrl() { + return this._azureDevopsProjectUrl; + } + get azurePipelineName() { + return this._azurePipelineName; + } + get azureDevopsToken() { + return this._azureDevopsToken; + } + get ref() { + return this._ref; + } + get sha() { + return this._sha; + } +} +exports.TaskParameters = TaskParameters; diff --git a/lib/util/logger.js b/lib/util/logger.js index 4c9b611a..3d284ea0 100644 --- a/lib/util/logger.js +++ b/lib/util/logger.js @@ -1,37 +1,37 @@ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(require("@actions/core")); -class Logger { - static LogOutputUrl(url) { - if (url) { - core.setOutput('pipeline-url', url); - core.info(`More details on triggered pipeline can be found here : "${url}"`); - } - } - static LogInfo(message) { - core.info(message); - } - static LogPipelineTriggered(pipelineName, projectName) { - core.info(`\Pipeline '${pipelineName}' is triggered in project '${projectName}'`); - } - static LogPipelineObject(object) { - core.debug("Pipeline object : " + this.getPrintObject(object)); - } - static LogPipelineTriggerInput(input) { - core.debug("Input: " + this.getPrintObject(input)); - } - static LogPipelineTriggerOutput(output) { - core.debug("Output: " + this.getPrintObject(output)); - } - static getPrintObject(object) { - return JSON.stringify(object, null, 4); - } -} -exports.Logger = Logger; +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(require("@actions/core")); +class Logger { + static LogOutputUrl(url) { + if (url) { + core.setOutput('pipeline-url', url); + core.info(`More details on triggered pipeline can be found here : "${url}"`); + } + } + static LogInfo(message) { + core.info(message); + } + static LogPipelineTriggered(pipelineName, projectName) { + core.info(`\Pipeline '${pipelineName}' is triggered in project '${projectName}'`); + } + static LogPipelineObject(object) { + core.debug("Pipeline object : " + this.getPrintObject(object)); + } + static LogPipelineTriggerInput(input) { + core.debug("Input: " + this.getPrintObject(input)); + } + static LogPipelineTriggerOutput(output) { + core.debug("Output: " + this.getPrintObject(output)); + } + static getPrintObject(object) { + return JSON.stringify(object, null, 4); + } +} +exports.Logger = Logger; diff --git a/lib/util/pipeline.helper.js b/lib/util/pipeline.helper.js index 78c77e6b..86ff73c6 100644 --- a/lib/util/pipeline.helper.js +++ b/lib/util/pipeline.helper.js @@ -1,92 +1,92 @@ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const BuildInterfaces = __importStar(require("azure-devops-node-api/interfaces/BuildInterfaces")); -const pipeline_error_1 = require("./../pipeline.error"); -class PipelineHelper { - static EnsureValidPipeline(projectName, pipelineName, pipelines) { - // If definition not found then Throw Error - if (pipelines == null || pipelines.length == 0) { - let errorMessage = `Pipeline named "${pipelineName}" not found in project "${projectName}"`; - throw new pipeline_error_1.PipelineNotFoundError(errorMessage); - } - if (pipelines.length > 1) { - // If more than 1 definition found, throw ERROR - let errorMessage = `More than 1 Pipeline named "${pipelineName}" found in project "${projectName}"`; - throw Error(errorMessage); - } - } - static equals(str1, str2) { - if (str1 === str2) { - return true; - } - if (str1 === null) { - return false; - } - if (str2 === null) { - return false; - } - return str1.trim().toUpperCase() === str2.trim().toUpperCase(); - } - static processEnv(envVarName) { - const variable = process.env[envVarName]; - if (!variable) { - throw new Error(`env.${envVarName} is not set`); - } - return variable; - } - ; - static isGitHubArtifact(arifact) { - if (arifact != null && arifact.type != null && arifact.type.toUpperCase() === "GITHUB") { - return true; - } - return false; - } - static getErrorAndWarningMessageFromBuildResult(validationResults) { - let errorMessage = ""; - let warningMessage = ""; - if (validationResults && validationResults.length > 0) { - let errors = validationResults.filter((result) => { - return result.result === BuildInterfaces.ValidationResult.Error; - }); - if (errors.length > 0) { - errorMessage = this._joinValidateResults(errors); - } - else { - warningMessage = this._joinValidateResults(validationResults); - } - } - // Taking into account server errors also which comes not in form of array, like no build queue permissions - else if (validationResults) { - errorMessage = this._getErrorMessageFromServer(validationResults); - } - return { - errorMessage: errorMessage, - warningMessage: warningMessage - }; - } - static _joinValidateResults(validateResults) { - let resultMessages = validateResults.map((validationResult) => { - return validationResult.message; - }); - resultMessages = resultMessages.filter((message) => !!message); - return resultMessages.join(","); - } - static _getErrorMessageFromServer(validationResult) { - let errorMessage = ""; - if (validationResult) { - errorMessage = validationResult.message || ""; - } - if (validationResult && validationResult.serverError && errorMessage.length === 0) { - errorMessage = validationResult.serverError.message || ""; - } - return errorMessage; - } -} -exports.PipelineHelper = PipelineHelper; +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const BuildInterfaces = __importStar(require("azure-devops-node-api/interfaces/BuildInterfaces")); +const pipeline_error_1 = require("./../pipeline.error"); +class PipelineHelper { + static EnsureValidPipeline(projectName, pipelineName, pipelines) { + // If definition not found then Throw Error + if (pipelines == null || pipelines.length == 0) { + let errorMessage = `Pipeline named "${pipelineName}" not found in project "${projectName}"`; + throw new pipeline_error_1.PipelineNotFoundError(errorMessage); + } + if (pipelines.length > 1) { + // If more than 1 definition found, throw ERROR + let errorMessage = `More than 1 Pipeline named "${pipelineName}" found in project "${projectName}"`; + throw Error(errorMessage); + } + } + static equals(str1, str2) { + if (str1 === str2) { + return true; + } + if (str1 === null) { + return false; + } + if (str2 === null) { + return false; + } + return str1.trim().toUpperCase() === str2.trim().toUpperCase(); + } + static processEnv(envVarName) { + const variable = process.env[envVarName]; + if (!variable) { + throw new Error(`env.${envVarName} is not set`); + } + return variable; + } + ; + static isGitHubArtifact(arifact) { + if (arifact != null && arifact.type != null && arifact.type.toUpperCase() === "GITHUB") { + return true; + } + return false; + } + static getErrorAndWarningMessageFromBuildResult(validationResults) { + let errorMessage = ""; + let warningMessage = ""; + if (validationResults && validationResults.length > 0) { + let errors = validationResults.filter((result) => { + return result.result === BuildInterfaces.ValidationResult.Error; + }); + if (errors.length > 0) { + errorMessage = this._joinValidateResults(errors); + } + else { + warningMessage = this._joinValidateResults(validationResults); + } + } + // Taking into account server errors also which comes not in form of array, like no build queue permissions + else if (validationResults) { + errorMessage = this._getErrorMessageFromServer(validationResults); + } + return { + errorMessage: errorMessage, + warningMessage: warningMessage + }; + } + static _joinValidateResults(validateResults) { + let resultMessages = validateResults.map((validationResult) => { + return validationResult.message; + }); + resultMessages = resultMessages.filter((message) => !!message); + return resultMessages.join(","); + } + static _getErrorMessageFromServer(validationResult) { + let errorMessage = ""; + if (validationResult) { + errorMessage = validationResult.message || ""; + } + if (validationResult && validationResult.serverError && errorMessage.length === 0) { + errorMessage = validationResult.serverError.message || ""; + } + return errorMessage; + } +} +exports.PipelineHelper = PipelineHelper; diff --git a/lib/util/url.parser.js b/lib/util/url.parser.js index 6688ca32..6f1d22e4 100644 --- a/lib/util/url.parser.js +++ b/lib/util/url.parser.js @@ -1,60 +1,60 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -class UrlParser { - static GetProjectName(projectUrl) { - if (this.IsNullOrEmpty(projectUrl)) { - throw new Error(this.NullOrEmptyProjectUrl); - } - try { - projectUrl = projectUrl.trim(); - this.EnsureProjectName(projectUrl); - var index = projectUrl.lastIndexOf("/"); - var projectNamePart = projectUrl.substr(index + 1); - var projectName = decodeURI(projectNamePart); - if (projectName) { - return projectName; - } - else { - throw Error(); - } - } - catch (error) { - var errorMessage = this.GetUrlParseExceptionMessage(projectUrl); - throw new Error(errorMessage); - } - } - static GetCollectionUrlBase(projectUrl) { - if (this.IsNullOrEmpty(projectUrl)) { - throw new Error(this.NullOrEmptyProjectUrl); - } - try { - projectUrl = projectUrl.trim(); - var collectionUrl = projectUrl.substr(0, projectUrl.lastIndexOf("/")); - if (collectionUrl) { - return collectionUrl; - } - else { - throw Error(); - } - } - catch (error) { - var errorMessage = this.GetUrlParseExceptionMessage(projectUrl); - throw new Error(errorMessage); - } - } - static EnsureProjectName(projectUrl) { - var index = projectUrl.lastIndexOf("/"); - if (index == (projectUrl.length - 1)) { - throw Error(); - } - } - static GetUrlParseExceptionMessage(projectUrl) { - let errorMessage = `Failed to parse project url: "${projectUrl}". Specify the valid project url (eg, https://dev.azure.com/organization/project-name or https://server.example.com:8080/tfs/DefaultCollection/project-name)) and try again.`; - return errorMessage; - } - static IsNullOrEmpty(value) { - return (!value); - } -} -exports.UrlParser = UrlParser; -UrlParser.NullOrEmptyProjectUrl = "Project url is null or empty. Specify the valid project url and try again"; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +class UrlParser { + static GetProjectName(projectUrl) { + if (this.IsNullOrEmpty(projectUrl)) { + throw new Error(this.NullOrEmptyProjectUrl); + } + try { + projectUrl = projectUrl.trim(); + this.EnsureProjectName(projectUrl); + var index = projectUrl.lastIndexOf("/"); + var projectNamePart = projectUrl.substr(index + 1); + var projectName = decodeURI(projectNamePart); + if (projectName) { + return projectName; + } + else { + throw Error(); + } + } + catch (error) { + var errorMessage = this.GetUrlParseExceptionMessage(projectUrl); + throw new Error(errorMessage); + } + } + static GetCollectionUrlBase(projectUrl) { + if (this.IsNullOrEmpty(projectUrl)) { + throw new Error(this.NullOrEmptyProjectUrl); + } + try { + projectUrl = projectUrl.trim(); + var collectionUrl = projectUrl.substr(0, projectUrl.lastIndexOf("/")); + if (collectionUrl) { + return collectionUrl; + } + else { + throw Error(); + } + } + catch (error) { + var errorMessage = this.GetUrlParseExceptionMessage(projectUrl); + throw new Error(errorMessage); + } + } + static EnsureProjectName(projectUrl) { + var index = projectUrl.lastIndexOf("/"); + if (index == (projectUrl.length - 1)) { + throw Error(); + } + } + static GetUrlParseExceptionMessage(projectUrl) { + let errorMessage = `Failed to parse project url: "${projectUrl}". Specify the valid project url (eg, https://dev.azure.com/organization/project-name or https://server.example.com:8080/tfs/DefaultCollection/project-name)) and try again.`; + return errorMessage; + } + static IsNullOrEmpty(value) { + return (!value); + } +} +exports.UrlParser = UrlParser; +UrlParser.NullOrEmptyProjectUrl = "Project url is null or empty. Specify the valid project url and try again"; diff --git a/src/pipeline.runner.ts b/src/pipeline.runner.ts index 94bb8465..6a94ac68 100644 --- a/src/pipeline.runner.ts +++ b/src/pipeline.runner.ts @@ -77,11 +77,23 @@ export class PipelineRunner { if (p.equals(repositoryId, this.repository) && p.equals(repositoryType, this.githubRepo)) { core.debug("pipeline is linked to same Github repo"); sourceBranch = this.branch, - sourceVersion = this.commitId + sourceVersion = this.commitId } else { core.debug("pipeline is not linked to same Github repo"); } + // If provided, the user-specified ref and sha override our implied branch + // and commit hash from GitHub. This is useful when we're using this action + // in workflows triggered by non-PR events (like issue_comment). + if (this.taskParameters.ref) { + sourceBranch = this.taskParameters.ref; + core.debug(`using user-specified ref ${sourceBranch}`); + } + if (this.taskParameters.sha) { + sourceVersion = this.taskParameters.sha; + core.debug(`using user-specified sha ${sourceVersion}`); + } + let build: BuildInterfaces.Build = { definition: { id: buildDefinition.id @@ -173,4 +185,4 @@ export class PipelineRunner { } } } -} \ No newline at end of file +} diff --git a/src/task.parameters.ts b/src/task.parameters.ts index a3bcf0f9..e6693088 100644 --- a/src/task.parameters.ts +++ b/src/task.parameters.ts @@ -5,11 +5,15 @@ export class TaskParameters { private _azureDevopsProjectUrl: string; private _azurePipelineName: string; private _azureDevopsToken: string; + private _ref: string; + private _sha: string; private constructor() { this._azureDevopsProjectUrl = core.getInput('azure-devops-project-url', { required: true }); this._azurePipelineName = core.getInput('azure-pipeline-name', { required: true }); this._azureDevopsToken = core.getInput('azure-devops-token', { required: true }); + this._ref = core.getInput('ref', { required: false }); + this._sha = core.getInput('sha', { required: false }); } public static getTaskParams() { @@ -31,4 +35,12 @@ export class TaskParameters { public get azureDevopsToken() { return this._azureDevopsToken; } -} \ No newline at end of file + + public get ref() { + return this._ref; + } + + public get sha() { + return this._sha; + } +} From 76f2d2d8dbf8aa6667f7f010e230fc57f553ce02 Mon Sep 17 00:00:00 2001 From: Elliot Nelson Date: Tue, 9 Mar 2021 12:20:48 -0500 Subject: [PATCH 2/2] Allow users to specify a build definition id specifically, to avoid using pipeline name. --- action.yml | 7 +++++-- lib/pipeline.runner.js | 24 +++++++++++++++--------- lib/task.parameters.js | 6 +++++- src/pipeline.runner.ts | 24 +++++++++++++++--------- src/task.parameters.ts | 8 +++++++- 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/action.yml b/action.yml index 4326e587..f6272276 100644 --- a/action.yml +++ b/action.yml @@ -5,8 +5,11 @@ inputs: description: 'Fullyqualified URL to the Azure DevOps organization along with project name(eg, https://dev.azure.com/organization/project-name or https://server.example.com:8080/tfs/DefaultCollection/project-name)' required: true azure-pipeline-name: - description: 'Name of the Azure Pipline to be triggered' - required: true + description: 'Name of the Azure Pipeline to be triggered' + required: false + azure-pipeline-id: + description: 'The build definition ID of the Azure Pipeline to be triggered' + required: false azure-devops-token: description: 'Paste personal access token of the user as value of secret variable:AZURE_DEVOPS_TOKEN' required: true diff --git a/lib/pipeline.runner.js b/lib/pipeline.runner.js index e6fed5ae..77605799 100644 --- a/lib/pipeline.runner.js +++ b/lib/pipeline.runner.js @@ -42,14 +42,14 @@ class PipelineRunner { core.info(`Creating connection with Azure DevOps service : "${collectionUrl}"`); let webApi = new azdev.WebApi(collectionUrl, authHandler); core.info("Connection created"); - let pipelineName = this.taskParameters.azurePipelineName; + let description = `(name="${this.taskParameters.azurePipelineName}", id=${this.taskParameters.azurePipelineId})`; try { - core.debug(`Triggering Yaml pipeline : "${pipelineName}"`); + core.debug(`Triggering Yaml pipeline : ${description}`); yield this.RunYamlPipeline(webApi); } catch (error) { if (error instanceof pipeline_error_1.PipelineNotFoundError) { - core.debug(`Triggering Designer pipeline : "${pipelineName}"`); + core.debug(`Triggering Designer pipeline : ${description}`); yield this.RunDesignerPipeline(webApi); } else { @@ -67,13 +67,19 @@ class PipelineRunner { return __awaiter(this, void 0, void 0, function* () { let projectName = url_parser_1.UrlParser.GetProjectName(this.taskParameters.azureDevopsProjectUrl); let pipelineName = this.taskParameters.azurePipelineName; + let buildDefinitionId = this.taskParameters.azurePipelineId ? parseInt(this.taskParameters.azurePipelineId, 10) : 0; let buildApi = yield webApi.getBuildApi(); - // Get matching build definitions for the given project and pipeline name - const buildDefinitions = yield buildApi.getDefinitions(projectName, pipelineName); - pipeline_helper_1.PipelineHelper.EnsureValidPipeline(projectName, pipelineName, buildDefinitions); - // Extract Id from build definition - let buildDefinitionReference = buildDefinitions[0]; - let buildDefinitionId = buildDefinitionReference.id; + // If the user passed a name instead of a definition id, search existing + // pipelines for that id. + if (!buildDefinitionId) { + // Get matching build definitions for the given project and pipeline name + const buildDefinitions = yield buildApi.getDefinitions(projectName, pipelineName); + pipeline_helper_1.PipelineHelper.EnsureValidPipeline(projectName, pipelineName, buildDefinitions); + // Extract Id from build definition + let buildDefinitionReference = buildDefinitions[0]; + pipelineName = buildDefinitionReference.name; + buildDefinitionId = buildDefinitionReference.id; + } // Get build definition for the matching definition Id let buildDefinition = yield buildApi.getDefinition(projectName, buildDefinitionId); logger_1.Logger.LogPipelineObject(buildDefinition); diff --git a/lib/task.parameters.js b/lib/task.parameters.js index ea411087..8aefe733 100644 --- a/lib/task.parameters.js +++ b/lib/task.parameters.js @@ -11,7 +11,8 @@ const core = __importStar(require("@actions/core")); class TaskParameters { constructor() { this._azureDevopsProjectUrl = core.getInput('azure-devops-project-url', { required: true }); - this._azurePipelineName = core.getInput('azure-pipeline-name', { required: true }); + this._azurePipelineName = core.getInput('azure-pipeline-name', { required: false }); + this._azurePipelineId = core.getInput('azure-pipeline-id', { required: false }); this._azureDevopsToken = core.getInput('azure-devops-token', { required: true }); this._ref = core.getInput('ref', { required: false }); this._sha = core.getInput('sha', { required: false }); @@ -28,6 +29,9 @@ class TaskParameters { get azurePipelineName() { return this._azurePipelineName; } + get azurePipelineId() { + return this._azurePipelineId; + } get azureDevopsToken() { return this._azureDevopsToken; } diff --git a/src/pipeline.runner.ts b/src/pipeline.runner.ts index 6a94ac68..ea42b527 100644 --- a/src/pipeline.runner.ts +++ b/src/pipeline.runner.ts @@ -29,14 +29,14 @@ export class PipelineRunner { let webApi = new azdev.WebApi(collectionUrl, authHandler); core.info("Connection created"); - let pipelineName = this.taskParameters.azurePipelineName; + let description = `(name="${this.taskParameters.azurePipelineName}", id=${this.taskParameters.azurePipelineId})`; try { - core.debug(`Triggering Yaml pipeline : "${pipelineName}"`); + core.debug(`Triggering Yaml pipeline : ${description}`); await this.RunYamlPipeline(webApi); } catch (error) { if (error instanceof PipelineNotFoundError) { - core.debug(`Triggering Designer pipeline : "${pipelineName}"`); + core.debug(`Triggering Designer pipeline : ${description}`); await this.RunDesignerPipeline(webApi); } else { throw error; @@ -51,16 +51,22 @@ export class PipelineRunner { public async RunYamlPipeline(webApi: azdev.WebApi): Promise { let projectName = UrlParser.GetProjectName(this.taskParameters.azureDevopsProjectUrl); let pipelineName = this.taskParameters.azurePipelineName; + let buildDefinitionId = this.taskParameters.azurePipelineId ? parseInt(this.taskParameters.azurePipelineId, 10) : 0; let buildApi = await webApi.getBuildApi(); - // Get matching build definitions for the given project and pipeline name - const buildDefinitions = await buildApi.getDefinitions(projectName, pipelineName); + // If the user passed a name instead of a definition id, search existing + // pipelines for that id. + if (!buildDefinitionId) { + // Get matching build definitions for the given project and pipeline name + const buildDefinitions = await buildApi.getDefinitions(projectName, pipelineName); - p.EnsureValidPipeline(projectName, pipelineName, buildDefinitions); + p.EnsureValidPipeline(projectName, pipelineName, buildDefinitions); - // Extract Id from build definition - let buildDefinitionReference: BuildInterfaces.BuildDefinitionReference = buildDefinitions[0]; - let buildDefinitionId = buildDefinitionReference.id; + // Extract Id from build definition + let buildDefinitionReference: BuildInterfaces.BuildDefinitionReference = buildDefinitions[0]; + pipelineName = buildDefinitionReference.name; + buildDefinitionId = buildDefinitionReference.id; + } // Get build definition for the matching definition Id let buildDefinition = await buildApi.getDefinition(projectName, buildDefinitionId); diff --git a/src/task.parameters.ts b/src/task.parameters.ts index e6693088..ce6ff120 100644 --- a/src/task.parameters.ts +++ b/src/task.parameters.ts @@ -4,13 +4,15 @@ export class TaskParameters { private static taskparams: TaskParameters; private _azureDevopsProjectUrl: string; private _azurePipelineName: string; + private _azurePipelineId: string; private _azureDevopsToken: string; private _ref: string; private _sha: string; private constructor() { this._azureDevopsProjectUrl = core.getInput('azure-devops-project-url', { required: true }); - this._azurePipelineName = core.getInput('azure-pipeline-name', { required: true }); + this._azurePipelineName = core.getInput('azure-pipeline-name', { required: false }); + this._azurePipelineId = core.getInput('azure-pipeline-id', { required: false }); this._azureDevopsToken = core.getInput('azure-devops-token', { required: true }); this._ref = core.getInput('ref', { required: false }); this._sha = core.getInput('sha', { required: false }); @@ -32,6 +34,10 @@ export class TaskParameters { return this._azurePipelineName; } + public get azurePipelineId() { + return this._azurePipelineId; + } + public get azureDevopsToken() { return this._azureDevopsToken; }