microsoft/azure-pipelines-task-lib

Running an "unpublished" TypeScript task on Azure Pipelines with node

jumattos opened this issue · 7 comments

Environment

azure-pipelines-task-lib version: 2.7.7

Question

My team has a build task that is shared with others via extension. I've been tasked with running integration tests as part of our CI to ensure the build task we ship is working properly across environments.

I am looking for the proper way to invoke the task on Azure Pipelines before releasing it. I thought I could invoke it with node, using a powershell script and setting the input as environment variables as suggested for running the task locally.

- powershell: |
  node $(Build.SourcesDirectory)/out/myTask.js
env: {
  "INPUT_MYINPUT": "my value"
}

Expected behaviour

I expected to have the same outcome as I do when I add - task: My-Task-Full-Name@0 to pipelines that have our extension installed.

Actual behaviour

I cannot see any of the logs printed to task.debug. The step succeeds but I can see that the task hasn't been executed correctly.

Are you seeing any output? Have you tried running this with system.debug=true?

Even with system.debug=true, I don't see much.

Here's how my output looks like:

"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'E:\A\_work\_temp\5aba09d8-8652-4f23-a744-2b566c2c9cd2.ps1'"
##[warning]Warning: <parameter> is deprecated setting. Please use <parameter> setting instead
Finishing: Run Unpublished Azure DevOps Build Task

This warning is from our build task, that gets me hopeful. Nothing is printed besides that, though. 😔

I also tried using the VstsTaskSdk PowerShell module, same results.

On the very first line of code we have a task.debug statement that I expected to see.

If you run that command locally, do you get your expected output?

To get it working locally, I need to replicate several environment variables found on Azure Pipelines: Agent.TempDirectory, Build.Repository.Provider, Build.Repository.Uri, Build.SourceBranch, Build.SourcesDirectory. However, if I do set all of these, I can invoke the task using node, and it does exactly what I expect to (besides just printing all my task.debug statements).

When I added the call to node on my pipeline, I only defined the input variables on "env". After your question, I went back and added all of those pipeline defined variables (even though they're supposed to be there already) in hopes that something would change. It didn't. I still get no task.debug statements.

If you'd like, you can message me on Teams (my name is pretty unique there) and I can try sharing the pipeline with you.

@damccorm - Do you mind helping out with this one?

Try setting the environment variables in the powershell script itself. Our task-lib grabs all the inputs you define in the environment, stores them, and wipes them from the environment (so they don't pollute user scripts). Since our powershell task uses the task-lib, it will wipe the env of the inputs you are setting.

This issue has had no activity in 90 days. Please comment if it is not actually stale