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.

  8. 8 Posted by w.n.bates on 19 Dec, 2018 10:57 AM

    w.n.bates's Avatar

    What's the correct way to install that on a machine that already has a deployment agent?
    I ran the downloaded file but it was unable to start up the new service at the end and then marks the service as disabled and for deletion. So I then needed to restart the server to be able to reinstall. I'm part way through right now on our test server and obv don't want to do a server reboot in prod.

  9. 9 Posted by w.n.bates on 19 Dec, 2018 11:04 AM

    w.n.bates's Avatar

    It's because the .net framework requirements have changed from the version we had installed. I'll need to install the latest .net framework components and get back to you.

  10. Support Staff 10 Posted by Ilya Finkelshte... on 19 Dec, 2018 08:04 PM

    Ilya Finkelshteyn's Avatar

    OK, please keep us in touch. Sorry for the hassle.

  11. 11 Posted by w.n.bates on 29 Jan, 2019 03:21 PM

    w.n.bates's Avatar

    So finally managed to get this tested and it all looks good with the latest version of the agent. Cheers for your help

  12. Support Staff 12 Posted by Ilya Finkelshte... on 29 Jan, 2019 10:46 PM

    Ilya Finkelshteyn's Avatar

    Thanks for the update :)

  13. Ilya Finkelshteyn closed this discussion on 29 Jan, 2019 10:46 PM.

Comments are currently closed for this discussion. You can start a new one.

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