Skip to content

Allowing env variables to be set without forcing VSTS_TASKVARIABLE_ prefix #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 194 commits into
base: master
Choose a base branch
from

Conversation

jeffw16
Copy link

@jeffw16 jeffw16 commented Jul 7, 2020

I'm currently developing an internal Microsoft ADO task that takes in an output variable from another task. It would be very helpful to be able to insert an output variable within the testing framework as well.

TingluoHuang and others added 30 commits August 29, 2017 10:39
…ent-version

Add TFS 2017 Update 3 agent version.
Deep Dive on Building Custom Build or Deploy Tasks
* Add task.json schema file

* Allow any "connectedService:" type of input

* Added the "id" field
Properly escape property value to handle non string types
* Error on multiline secret

* v2.3.0
Keegan Campbell and others added 26 commits November 14, 2019 18:07
Added:
- Groups: visibleRule
- DataSourceBindings: endpointUrl
- DataSourceBindings: resultSelector
In fact the handling of these properties already allows for them to be undefined/null. But the annotations didn't indicate this.
Since the entire options object was optional, having a couple properties on it *not* optional makes it hard to start supplying *any* options since the user must figure out what values to supply for these two properties to get equivalent behavior, in order to set some *other* option on the object.
While it doesn't make any sense, the typings for `process.env` is:

```ts
    interface ProcessEnv {
        [key: string]: string | undefined;
    }
```

So assigning `process.env` to `IExecSyncOptions.env` in typescript with all typings turned on produces compiler errors (at least when strict null checking is applied).

Without this simple typings adjustment, the following workaround in user code is required:

```ts
function GetFilteredEnv() {
    const result = {};
    const block = process.env;
    for (const key in block) {
        if (block.hasOwnProperty(key)) {
            const value = block[key];
            if (value !== undefined) {
                result[key] = value;
            }
        }
    }
    return result;
}

let options: IExecSyncOptions = { env: GetFilteredEnv() };
```

But with this change it's as simple as:

```ts
let options: IExecSyncOptions = { env: process.env };
```

Which ironically is already what is done *within* this repo, but isn't a problem because the node typings aren't imported so `process.env` is typed as `any`.
Co-authored-by: Tommy Petty <jopetty@microsoft.comwq>
Adding execution options on the pre-job stage.
The previous code example had `tr.exec()` on line 8. However, it should be `atool.exec()`.
* Added shell property to IExecOptions

Added shell property to IExecOptions to allow this property to be specified in pipelines tasks code. This option allows to handle variables in command the way it's needed.

* Incremented versions
…rosoft#638)

* Permit getDelimitedInput to split on either a string or a Regexp

* Add test for splitting on regexp

* Add missing argument

* Remove extra arg

Co-authored-by: Morgan Rodgers <morgan.rodgers@preventiongenetics.com>
* Wrapped tool path with quotes for running inside shell

* Refactored toolrunner.ts

* Increased version

* Updated package-lock.json

* Moved RegExp to separate variable

* Moved toolPath wrapping to separate method

* Revert "Updated package-lock.json"

This reverts commit ad943d1.

* Fixed package-lock.json

* Added exec and execSync tests

* Improved arguments handling for inside shell execution

* Added tests and moved them to separate section.

* Fixed Linux tests

* Fixed quotes handling test

* Fixed tests to support macOS

* Minor code cleanup.

* Made cmdSpecialChars constant readonly

* Minor refactoring

* Refactored arguments unwrapping

* Removed redundant import.

* Changes in accordance with review points

* Refactored in accordance with review points

* Fixed JSDocs
@jeffw16
Copy link
Author

jeffw16 commented Aug 4, 2020

Any update on whether this could be integrated into the library please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.