vercel-azure-devops-extension icon indicating copy to clipboard operation
vercel-azure-devops-extension copied to clipboard

Sequential deployments with multiple project Ids

Open jroho opened this issue 1 year ago • 0 comments

Currently, it's impossible to run deployments to multiple projects within a single pipeline. This is not ideal behavior. The notes within the vercel-deployment-task-source indicate this should be possible. I believe have corrected the problem in the reconcileConfigurationInput. Please let me know if my assumptions are incorrect:

/**
 * To reconcile configuration inputs, get both the _input_ and the _environment variable_.
 *
 * If neither are defined, throw an error.
 *
 * If both are defined, log a warning that _input_ will be used.
 *
 * If _input_ is defined, and not _environment variable_, set the _environment variable_ to the _input_ value and return the _input_ value.
 *
 * If _environment variable_ is defined, and not _input_, return the _environment variable_ value.
 *
 * @param configurationInput
 * @returns
 */
function reconcileConfigurationInput(
  inputKey: string,
  envVarKey: string,
  name: string,
  defaultValue?: string
): string {
  const inputValue = getInput(inputKey);
  const envVarValue = getVariable(envVarKey);

  if (inputValue && envVarValue) {
    console.warn(
      `${name} specified by both \`${inputKey}\` input and \`${envVarKey}\` environment variable. Input field \`${inputKey}\` will be used.`
    );
  }

  if (inputValue) {
    setVariable(envVarKey, inputValue);
    return inputValue;
  } else if (envVarValue) {
    setVariable(envVarKey, envVarValue);
    return envVarValue;
  } else if (defaultValue) {
    setVariable(envVarKey, defaultValue);
    return defaultValue;
  } else {
    throw new Error(
      `${name} must be specified using input \`${inputKey}\` or environment variable \`${envVarKey}\``
    );
  }

The only workaround I've is resetting the environment variable "VERCEL_PROJECT_ID" between executions:

- script: | echo "##vso[task.setvariable variable=VERCEL_PROJECT_ID]"

reference: https://github.com/orgs/vercel/discussions/3442

jroho avatar Mar 10 '24 05:03 jroho