How to use the azure-pipelines-task-lib/task.setVariable function in azure-pipelines-task-lib

To help you get started, we’ve selected a few azure-pipelines-task-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jfrog / artifactory-vsts-extension / tasks / ArtifactoryToolsInstaller / toolsInstaller.js View on Github external
let serverId = buildName + "-" + buildNumber + "-forextractordownload";
    try {
        utils.configureCliServer(artifactoryService, serverId, cliPath, workDir);
    } catch (ex) {
        tl.setResult(tl.TaskResult.Failed, ex);
        try {
            utils.deleteCliServers(cliPath, workDir, [serverId]);
        } catch (deleteServersException) {
            tl.setResult(tl.TaskResult.Failed, deleteServersException);
        }
        return
    }

    // Set the environment variables needed for the cli to download the extractor from artifactory
    // The extractor download will occur during the execution of the Artifactory Maven task, then the config and environment variables will be removed
    tl.setVariable("JFROG_CLI_JCENTER_REMOTE_SERVER", serverId);
    tl.setVariable("JFROG_CLI_JCENTER_REMOTE_REPO", tl.getInput("mavenInstallationRepo"));
    tl.setResult(tl.TaskResult.Succeeded, "Tools installed successfully.")
}
github microsoft / azure-pipelines-tasks / Tasks / AzureIoTEdgeV2 / deployimage.ts View on Github external
return; // There is no custom module so do not need to validate
      }

      let credentials = deploymentJson.modulesContent.$edgeAgent["properties.desired"].runtime.settings.registryCredentials;
      if (credentials) {
        Object.keys(credentials).forEach((key: string) => {
          let credential = credentials[key];
          let loginResult = tl.execSync("docker", `login ${credential.address} -u ${credential.username} -p ${credential.password}`, Constants.execSyncSilentOption);
          tl.debug(JSON.stringify(loginResult));
          if (loginResult.code != 0) {
            tl.warning(tl.loc("InvalidRegistryCredentialWarning", credential.address, loginResult.stderr));
          }
        });
      }

      tl.setVariable("DOCKER_CLI_EXPERIMENTAL", "enabled");
      tl.debug(`Checking DOCKER_CLI_EXPERIMENTAL value: ${tl.getVariable("DOCKER_CLI_EXPERIMENTAL")}`);
      let validationErr = "";
      Object.keys(modules).forEach((key: string) => {
        let module = modules[key];
        let image = module.settings.image;
        let manifestResult = tl.execSync("docker", `manifest inspect ${image}`, Constants.execSyncSilentOption);
        tl.debug(JSON.stringify(manifestResult));
        if (manifestResult.code != 0) {
          validationErr += tl.loc("CheckModuleImageExistenceError", image, manifestResult.stderr) + "\n";
        }
      });
      if (validationErr) {
        throw new Error(validationErr);
      }
    }
    catch (err) {
github microsoft / azure-pipelines-tasks / Tasks / UseGoV1 / installer.ts View on Github external
function setGoEnvironmentVariables(goRoot: string) {
    tl.setVariable('GOROOT', goRoot);

    const goPath: string = tl.getInput("goPath", false);
    const goBin: string = tl.getInput("goBin", false);

    // set GOPATH and GOBIN as user value
    if (!util.isNullOrUndefined(goPath)) {
        tl.setVariable("GOPATH", goPath);
    }
    if (!util.isNullOrUndefined(goBin)) {
        tl.setVariable("GOBIN", goBin);
    }
}
github microsoft / azure-pipelines-tasks / Tasks / GoToolV0 / gotool.ts View on Github external
function setGoEnvironmentVariables(goRoot: string) {
    tl.setVariable('GOROOT', goRoot);

    let goPath: string = tl.getInput("goPath", false);
    let goBin: string = tl.getInput("goBin", false);

    // set GOPATH and GOBIN as user value
    if (!util.isNullOrUndefined(goPath)) {
        tl.setVariable("GOPATH", goPath);
    }
    if (!util.isNullOrUndefined(goBin)) {
        tl.setVariable("GOBIN", goBin);
    }
}
github microsoft / azure-pipelines-tasks / Tasks / UseGoV1 / installer.ts View on Github external
function setGoEnvironmentVariables(goRoot: string) {
    tl.setVariable('GOROOT', goRoot);

    const goPath: string = tl.getInput("goPath", false);
    const goBin: string = tl.getInput("goBin", false);

    // set GOPATH and GOBIN as user value
    if (!util.isNullOrUndefined(goPath)) {
        tl.setVariable("GOPATH", goPath);
    }
    if (!util.isNullOrUndefined(goBin)) {
        tl.setVariable("GOBIN", goBin);
    }
}
github aws / aws-vsts-tools / Tasks / BeanstalkDeployApplication / TaskOperations.ts View on Github external
this.taskParameters.environmentName,
            versionLabel,
            this.taskParameters.description,
            this.taskParameters.applicationType === applicationTypeExistingVersion
        )

        await this.waitForDeploymentCompletion(
            this.taskParameters.applicationName,
            this.taskParameters.environmentName,
            startingEventDate,
            this.taskParameters.eventPollingDelay
        )

        if (this.taskParameters.outputVariable) {
            console.log(tl.loc('SettingOutputVariable', this.taskParameters.outputVariable, versionLabel))
            tl.setVariable(this.taskParameters.outputVariable, versionLabel)
        }

        console.log(tl.loc('TaskCompleted', this.taskParameters.applicationName))
    }
github microsoft / azure-devops-extension-tasks / BuildTasks / TfxInstaller / TfxInstaller.ts View on Github external
}

            toolPath = toolLib.findLocalTool('tfx', version);
        }

        if (!toolPath) {
            toolPath = await acquireTfx(version);
        }
    }

    if (os.platform() !== "win32")
    {
        toolPath = path.join(toolPath, "/node_modules/.bin/");
    }
    
    taskLib.setVariable("__tfxpath", toolPath, false);
    toolLib.prependPath(toolPath);
}
github microsoft / azure-pipelines-tasks / Tasks / KubernetesManifestV0 / src / models / kubernetesconnection.ts View on Github external
public close() {
        if (tl.getVariable('KUBECONFIG')) {
            tl.setVariable('KUBECONFIG', '');
        }
    }
}