Agent Deployments different depending if triggered by build vs using the webui/api

w.n.bates's Avatar


04 Dec, 2018 10:46 AM

We use a before-deploy.ps1 script as part of a web deployment on a private project.
The deployment condition is appveyor_repo_tag = true
Such that at the end of the build log we get

Deploying using Environment provider Started deployment to test environment

The script that runs uses postgres command line tools. But when triggered in the above way fails saying it cannot find the tools.

pg_restore : The term 'pg_restore' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

However if I then trigger a deployment using the API or Web UI it works without any issues.
The only conclusion I can draw is that the PATH variable is different depending on how the build was triggered.
Is this known behaviour? Why does this occur? Which is correct?

  1. Support Staff 1 Posted by Owen McDonnell on 05 Dec, 2018 07:29 AM

    Owen McDonnell's Avatar

    Can you share the configuration file in yaml format.

    Have you read through this section of the docs. I'm asking since you mentioned asynchronous deployment via API and UI are working.

  2. 2 Posted by w.n.bates on 05 Dec, 2018 07:56 AM

    w.n.bates's Avatar

    I've read that but can't see how that would lead to differences depending on how the deployment is triggered?
    Yaml below. Most of the build is handed off to a set of cake scripts.

    version: 1.0.{build}
    image: Visual Studio 2017
        secure: ********************
      PGUSER: postgres
      PGPASSWORD: Password12!
    - postgresql
    - iis
    - ps: .\build.ps1
    test: off
    - provider: GitHub
        secure: ****************
        appveyor_repo_tag: true
    - provider: Environment
      name: testmt
        appveyor_repo_tag: true
  3. Support Staff 3 Posted by Owen McDonnell on 05 Dec, 2018 07:43 PM

    Owen McDonnell's Avatar

    Build environment variables are not present when you deploy asynchronously (i.e. outside the context of the build).
    So do you have any variables configured in the environment to which you're deploying?

  4. 4 Posted by w.n.bates on 11 Dec, 2018 08:57 AM

    w.n.bates's Avatar

    Hi Sorry for the delay in replying.
    The only environment variable I think it needs to use postgres is the PATH. The system path on the deployment machine has postgres's dir in it. Would the PATH variable change?

  5. Support Staff 5 Posted by Owen McDonnell on 11 Dec, 2018 06:45 PM

    Owen McDonnell's Avatar

    Well if you are using an agent deployment environment, the before-deploy.ps1 script you're referring to runs on the target server.
    Though i'm still not certain why the results would differ when you trigger a deployment from UI or API.

    I would need to get a closer look at your configuration of the environment and the project to help further. You could either provide relevant screenshots/config files/scripts or make me a collaborator in your account and grant me access to that project and environment.

  6. 6 Posted by w.n.bates on 14 Dec, 2018 04:03 PM

    w.n.bates's Avatar

    I've confirmed that the PATH variable for the processes if different depending on how the build is triggered.
    It appears that using the deployment agent the process PATH variable is the same as the one used on the build agent despite running on a different machine.

    It sounds like as part of what you mentioned above it's also overwriting the PATH variable when being deployed at the end of the build. Is that correct behaviour? I can imagine the use case for environment variables other than PATH.

  7. Support Staff 7 Posted by Owen McDonnell on 14 Dec, 2018 06:45 PM

    Owen McDonnell's Avatar

    My colleague informed me he encountered a bug in the deployment agent similar to what you're experiencing. Can you try this patched agent and see if it behaves more consistently.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac