diff --git a/Tasks/DockerV2/dockerpush.ts b/Tasks/DockerV2/dockerpush.ts index 62843dc27f08..c84060c5c36e 100644 --- a/Tasks/DockerV2/dockerpush.ts +++ b/Tasks/DockerV2/dockerpush.ts @@ -143,26 +143,21 @@ async function publishToImageMetadataStore(connection: ContainerConnection, imag imageFingerPrint = dockerCommandUtils.getImageFingerPrint(imageRootfsLayers, v1Name); } - const addPipelineData = tl.getBoolInput("addPipelineData"); - // Getting pipeline variables const build = "build"; const hostType = tl.getVariable("System.HostType").toLowerCase(); const runId = hostType === build ? parseInt(tl.getVariable("Build.BuildId")) : parseInt(tl.getVariable("Release.ReleaseId")); - const pipelineVersion = addPipelineData ? hostType === build ? tl.getVariable("Build.BuildNumber") : tl.getVariable("Release.ReleaseName") : ""; - const pipelineName = addPipelineData ? tl.getVariable("System.DefinitionName") : ""; - const pipelineId = addPipelineData ? tl.getVariable("System.DefinitionId") : ""; - const jobName = addPipelineData ? tl.getVariable("System.PhaseDisplayName") : ""; - const creator = addPipelineData ? dockerCommandUtils.getCreatorEmail() : ""; - const logsUri = addPipelineData ? dockerCommandUtils.getPipelineLogsUrl() : ""; - const artifactStorageSourceUri = addPipelineData ? dockerCommandUtils.getPipelineUrl() : ""; - - const repoUrl = tl.getVariable("Build.Repository.Uri"); - const contextUrl = addPipelineData && repoUrl ? repoUrl : ""; - - const commitId = tl.getVariable("Build.SourceVersion"); - const revisionId = addPipelineData && commitId ? commitId : ""; + const pipelineVersion = hostType === build ? tl.getVariable("Build.BuildNumber") : tl.getVariable("Release.ReleaseName"); + const pipelineName = tl.getVariable("System.DefinitionName"); + const pipelineId = tl.getVariable("System.DefinitionId"); + const jobName = tl.getVariable("System.PhaseDisplayName"); + const creator = dockerCommandUtils.getCreatorEmail(); + const logsUri = dockerCommandUtils.getPipelineLogsUrl(); + const artifactStorageSourceUri = dockerCommandUtils.getPipelineUrl(); + const contextUrl = tl.getVariable("Build.Repository.Uri") || ""; + const revisionId = tl.getVariable("Build.SourceVersion") || ""; + const addPipelineData = tl.getBoolInput("addPipelineData"); const labelArguments = pipelineUtils.getDefaultLabels(addPipelineData); const buildOptions = dockerCommandUtils.getBuildAndPushArguments(dockerFilePath, labelArguments, tags); diff --git a/Tasks/DockerV2/task.json b/Tasks/DockerV2/task.json index d3daa6b4cb85..4e9e4b06eb88 100644 --- a/Tasks/DockerV2/task.json +++ b/Tasks/DockerV2/task.json @@ -13,6 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, +<<<<<<< HEAD <<<<<<< HEAD "Minor": 160, <<<<<<< HEAD @@ -32,6 +33,10 @@ ======= "Patch": 2 >>>>>>> Removing img change +======= + "Minor": 162, + "Patch": 0 +>>>>>>> Removed the publish metadata pipeline variable (#11766) }, "demands": [], "releaseNotes": "Simplified the task YAML by:
 - Removing the Container registry type input
 - Removing complex inputs as they can be passed as arguments to the command.", diff --git a/Tasks/DockerV2/task.loc.json b/Tasks/DockerV2/task.loc.json index ce5cfa19cb90..83cba744e8e7 100644 --- a/Tasks/DockerV2/task.loc.json +++ b/Tasks/DockerV2/task.loc.json @@ -13,6 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 2, +<<<<<<< HEAD <<<<<<< HEAD "Minor": 160, <<<<<<< HEAD @@ -32,6 +33,10 @@ ======= "Patch": 2 >>>>>>> Removing img change +======= + "Minor": 162, + "Patch": 0 +>>>>>>> Removed the publish metadata pipeline variable (#11766) }, "demands": [], "releaseNotes": "ms-resource:loc.releaseNotes", diff --git a/Tasks/HelmDeployV0/src/helm.ts b/Tasks/HelmDeployV0/src/helm.ts index 9084f566a680..98cafdb2833c 100644 --- a/Tasks/HelmDeployV0/src/helm.ts +++ b/Tasks/HelmDeployV0/src/helm.ts @@ -15,7 +15,6 @@ import fs = require('fs'); import * as commonCommandOptions from "./commoncommandoption"; tl.setResourcePath(path.join(__dirname, '..', 'task.json')); -const publishPipelineMetadata = tl.getVariable("PUBLISH_PIPELINE_METADATA"); function getKubeConfigFilePath(): string { var userdir = helmutil.getTaskTempDir(); @@ -124,7 +123,7 @@ function runHelm(helmCli: helmcli, command: string, kubectlCli: kubernetescli) { tl.debug('execResult: ' + JSON.stringify(execResult)); tl.setResult(tl.TaskResult.Failed, execResult.stderr); } - else if ((command === "install" || command === "upgrade") && publishPipelineMetadata && publishPipelineMetadata.toLowerCase() == "true") { + else if ((command === "install" || command === "upgrade")) { let output = execResult.stdout; let manifests = extractManifestsFromHelmOutput(output); if (manifests && manifests.length > 0) { diff --git a/Tasks/HelmDeployV0/task.json b/Tasks/HelmDeployV0/task.json index 5552d24eac5e..101b95cba6db 100644 --- a/Tasks/HelmDeployV0/task.json +++ b/Tasks/HelmDeployV0/task.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 0, - "Minor": 160, + "Minor": 162, "Patch": 0 }, "demands": [], diff --git a/Tasks/HelmDeployV0/task.loc.json b/Tasks/HelmDeployV0/task.loc.json index 0154060df0d3..62af32b9952a 100644 --- a/Tasks/HelmDeployV0/task.loc.json +++ b/Tasks/HelmDeployV0/task.loc.json @@ -13,7 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 0, - "Minor": 160, + "Minor": 162, "Patch": 0 }, "demands": [], diff --git a/Tasks/KubernetesManifestV0/src/utils/DeploymentHelper.ts b/Tasks/KubernetesManifestV0/src/utils/DeploymentHelper.ts index c5fceb4cc85a..2d46d69b70eb 100644 --- a/Tasks/KubernetesManifestV0/src/utils/DeploymentHelper.ts +++ b/Tasks/KubernetesManifestV0/src/utils/DeploymentHelper.ts @@ -21,8 +21,6 @@ import { WebRequest, sendRequest } from 'utility-common-v2/restutilities'; import { deployPodCanary } from './PodCanaryDeploymentHelper'; import { deploySMICanary } from './SMICanaryDeploymentHelper'; -const publishPipelineMetadata = tl.getVariable("PUBLISH_PIPELINE_METADATA"); - export async function deploy(kubectl: Kubectl, manifestFilePaths: string[], deploymentStrategy: string) { // get manifest files @@ -51,9 +49,8 @@ export async function deploy(kubectl: Kubectl, manifestFilePaths: string[], depl const allPods = JSON.parse((kubectl.getAllPods()).stdout); annotateResources(deployedManifestFiles, kubectl, resourceTypes, allPods); - // Capture and push deployment metadata only if the variable 'PUBLISH_PIPELINE_METADATA' is set to true, - // and deployment strategy is not specified (because for Canary/SMI we do not replace actual deployment objects) - if (publishPipelineMetadata && publishPipelineMetadata.toLowerCase() == "true" && !isCanaryDeploymentStrategy(deploymentStrategy)) { + // Capture and push deployment metadata only if deployment strategy is not specified (because for Canary/SMI we do not replace actual deployment objects) + if (!isCanaryDeploymentStrategy(deploymentStrategy)) { try { const clusterInfo = kubectl.getClusterInfo().stdout; captureAndPushDeploymentMetadata(inputManifestFiles, allPods, deploymentStrategy, clusterInfo, manifestFilePaths); diff --git a/Tasks/KubernetesManifestV0/task.json b/Tasks/KubernetesManifestV0/task.json index 114bbcd34450..584f20ad3cd8 100644 --- a/Tasks/KubernetesManifestV0/task.json +++ b/Tasks/KubernetesManifestV0/task.json @@ -13,6 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 0, +<<<<<<< HEAD "Minor": 160, <<<<<<< HEAD <<<<<<< HEAD @@ -35,6 +36,10 @@ ======= "Patch": 7 >>>>>>> Removing img change +======= + "Minor": 162, + "Patch": 0 +>>>>>>> Removed the publish metadata pipeline variable (#11766) }, "demands": [], "groups": [], diff --git a/Tasks/KubernetesManifestV0/task.loc.json b/Tasks/KubernetesManifestV0/task.loc.json index 70046cae5cc4..3546b982da3a 100644 --- a/Tasks/KubernetesManifestV0/task.loc.json +++ b/Tasks/KubernetesManifestV0/task.loc.json @@ -13,6 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 0, +<<<<<<< HEAD "Minor": 160, <<<<<<< HEAD <<<<<<< HEAD @@ -35,6 +36,10 @@ ======= "Patch": 7 >>>>>>> Removing img change +======= + "Minor": 162, + "Patch": 0 +>>>>>>> Removed the publish metadata pipeline variable (#11766) }, "demands": [], "groups": [], diff --git a/Tasks/KubernetesV1/src/kubernetes.ts b/Tasks/KubernetesV1/src/kubernetes.ts index ef600ff79f2f..e47317cbf17c 100644 --- a/Tasks/KubernetesV1/src/kubernetes.ts +++ b/Tasks/KubernetesV1/src/kubernetes.ts @@ -19,7 +19,6 @@ tl.cd(tl.getInput("cwd")); var registryType = tl.getInput("containerRegistryType", true); var command = tl.getInput("command", false); const environmentVariableMaximumSize = 32766; -const publishPipelineMetadata = tl.getVariable("PUBLISH_PIPELINE_METADATA"); var kubeconfigfilePath; if (command === "logout") { @@ -118,43 +117,57 @@ function executeKubectlCommand(clusterConnection: ClusterConnection, command: st const outputFormat: string = tl.getInput("outputFormat", false); const isOutputFormatSpecified: boolean = outputFormat && (outputFormat.toLowerCase() === "json" || outputFormat.toLowerCase() === "yaml"); // The deployment data is pushed to evidence store only for commands like 'apply' or 'create' which support Json and Yaml output format - if (publishPipelineMetadata && publishPipelineMetadata.toLowerCase() == "true" && isOutputFormatSpecified && isJsonOrYamlOutputFormatSupported(command)) { - const allPods = JSON.parse(getAllPods(clusterConnection).stdout); - const clusterInfo = getClusterInfo(clusterConnection).stdout; - - let fileArgs = ""; - const configFilePathArgs = getCommandConfigurationFile(); - if (configFilePathArgs.length > 0) { - fileArgs = configFilePathArgs.join(" "); + if (isOutputFormatSpecified && isJsonOrYamlOutputFormatSupported(command)) { + let podsOutputString: string = ""; + try { + podsOutputString = getAllPods(clusterConnection).stdout; } - else { - fileArgs = tl.getInput("arguments", false); + catch (e) { + tl.debug("Not pushing metadata to artifact metadata store as failed to retrieve container pods; Error: " + e); + return; + } + + if (!IsJsonString(podsOutputString)) { + tl.debug("Not pushing metadata to artifact metadata store as failed to retrieve container pods"); } + else { + const allPods = JSON.parse(podsOutputString); + const clusterInfo = getClusterInfo(clusterConnection).stdout; - const manifestUrls = getManifestFileUrlsFromArgumentsInput(fileArgs); - // For each output, check if it contains a JSON object - result.forEach(res => { - let parsedObject: any; - if (IsJsonString(res)) { - parsedObject = JSON.parse(res); + let fileArgs = ""; + const configFilePathArgs = getCommandConfigurationFile(); + if (configFilePathArgs.length > 0) { + fileArgs = configFilePathArgs.join(" "); } else { - parsedObject = yaml.safeLoad(res); + fileArgs = tl.getInput("arguments", false); } - // Check if the output contains a deployment - if (parsedObject.kind && isDeploymentEntity(parsedObject.kind)) { - try { - pushDeploymentDataToEvidenceStore(clusterConnection, parsedObject, allPods, clusterInfo, manifestUrls).then((result) => { - tl.debug("DeploymentDetailsApiResponse: " + JSON.stringify(result)); - }, (error) => { - tl.warning("publishToImageMetadataStore failed with error: " + error); - }); + + const manifestUrls = getManifestFileUrlsFromArgumentsInput(fileArgs); + // For each output, check if it contains a JSON object + result.forEach(res => { + let parsedObject: any; + if (IsJsonString(res)) { + parsedObject = JSON.parse(res); } - catch (e) { - tl.warning("Capturing deployment metadata failed with error: " + e); + else { + parsedObject = yaml.safeLoad(res); } - } - }); + // Check if the output contains a deployment + if (parsedObject.kind && isDeploymentEntity(parsedObject.kind)) { + try { + pushDeploymentDataToEvidenceStore(clusterConnection, parsedObject, allPods, clusterInfo, manifestUrls).then((result) => { + tl.debug("DeploymentDetailsApiResponse: " + JSON.stringify(result)); + }, (error) => { + tl.warning("publishToImageMetadataStore failed with error: " + error); + }); + } + catch (e) { + tl.warning("Capturing deployment metadata failed with error: " + e); + } + } + }); + } } }); } diff --git a/Tasks/KubernetesV1/task.json b/Tasks/KubernetesV1/task.json index 1ee4ff0b4d95..d89ff60a4dc8 100644 --- a/Tasks/KubernetesV1/task.json +++ b/Tasks/KubernetesV1/task.json @@ -13,6 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, +<<<<<<< HEAD <<<<<<< HEAD "Minor": 160, <<<<<<< HEAD @@ -38,6 +39,9 @@ >>>>>>> Removing img change ======= "Minor": 161, +======= + "Minor": 162, +>>>>>>> Removed the publish metadata pipeline variable (#11766) "Patch": 0 >>>>>>> Kubernetes L0 fix (#11781) }, diff --git a/Tasks/KubernetesV1/task.loc.json b/Tasks/KubernetesV1/task.loc.json index df2326f51dc3..e47e81325f28 100644 --- a/Tasks/KubernetesV1/task.loc.json +++ b/Tasks/KubernetesV1/task.loc.json @@ -13,6 +13,7 @@ "author": "Microsoft Corporation", "version": { "Major": 1, +<<<<<<< HEAD <<<<<<< HEAD "Minor": 160, <<<<<<< HEAD @@ -38,6 +39,9 @@ >>>>>>> Removing img change ======= "Minor": 161, +======= + "Minor": 162, +>>>>>>> Removed the publish metadata pipeline variable (#11766) "Patch": 0 >>>>>>> Kubernetes L0 fix (#11781) }, diff --git a/make-options.json b/make-options.json index 0b245792b3c7..b537dd3be8cd 100644 --- a/make-options.json +++ b/make-options.json @@ -135,7 +135,6 @@ "PublishCodeCoverageResultsV1", "PublishPipelineArtifactV0", "PublishPipelineArtifactV1", - "PublishPipelineMetadataV0", "PublishSymbolsV2", "PublishTestResultsV1", "PublishTestResultsV2",