Agent Deployments different depending if triggered by build vs using the webui/api
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?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | 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
Support Staff 1 Posted by Owen McDonnell on 05 Dec, 2018 07:29 AM
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 Posted by w.n.bates on 05 Dec, 2018 07:56 AM
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.
Support Staff 3 Posted by Owen McDonnell on 05 Dec, 2018 07:43 PM
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 Posted by w.n.bates on 11 Dec, 2018 08:57 AM
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?
Support Staff 5 Posted by Owen McDonnell on 11 Dec, 2018 06:45 PM
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 Posted by w.n.bates on 14 Dec, 2018 04:03 PM
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.
Support Staff 7 Posted by Owen McDonnell on 14 Dec, 2018 06:45 PM
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 Posted by w.n.bates on 19 Dec, 2018 10:57 AM
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 Posted by w.n.bates on 19 Dec, 2018 11:04 AM
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.
Support Staff 10 Posted by Ilya Finkelshte... on 19 Dec, 2018 08:04 PM
OK, please keep us in touch. Sorry for the hassle.
11 Posted by w.n.bates on 29 Jan, 2019 03:21 PM
So finally managed to get this tested and it all looks good with the latest version of the agent. Cheers for your help
Support Staff 12 Posted by Ilya Finkelshte... on 29 Jan, 2019 10:46 PM
Thanks for the update :)
Ilya Finkelshteyn closed this discussion on 29 Jan, 2019 10:46 PM.