tag:help.appveyor.com,2012-11-13:/discussions/questions/860-how-can-i-run-my-own-powershell-script-after-the-build-stepAppVeyor: Discussion 2018-10-19T08:16:57Ztag:help.appveyor.com,2012-11-13:Comment/357519822015-01-12T07:37:36Z2015-01-12T07:37:36ZHow can I run my own powershell script AFTER the build step?<div><p>Hello,</p>
<p>Is this:</p>
<p><a href=
"https://github.com/chocolatey/ChocolateyGUI/blob/develop/appveyor.yml#L29">
https://github.com/chocolatey/ChocolateyGUI/blob/develop/appveyor.y...</a></p>
<p>What you are looking for?</p>
<p><code>build.ps1</code> is a PowerShell script that is stored in
my repository, and I run this as the first step in my build.</p>
<p>Hope that helps!</p>
<p>Gary</p></div>gep13tag:help.appveyor.com,2012-11-13:Comment/357519822015-01-12T07:39:55Z2015-01-12T07:39:55ZHow can I run my own powershell script AFTER the build step?<div><p>Hi @gep13 - thanks heaps for looking at my question. I really
appreciate it, mate.</p>
<p>Um, nope. Your build script is the -full- build script (for your
repo). I was just wanting to have my own deployment script (i guess
i've renamed my script wrong - le blush!).</p>
<p>so it's like .. after the tests all work, run this PS
script.</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-12T17:46:54Z2015-01-12T17:46:54ZHow can I run my own powershell script AFTER the build step?<div><p>You can use "Script" mode on Deployment tab or
<code>deploy_script</code> in <code>appveyor.yml</code>.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T00:11:26Z2015-01-13T00:11:26ZHow can I run my own powershell script AFTER the build step?<div><p>thanks @feodor :)</p>
<p>one last question about this ... we :heart: using
<code>appveyor.yml</code> scripts (instead of the ui).</p>
<p>is there a way we can only run the deploy script when the git
branch is <code>master</code> ? for everything else - there is no
deploy script / no deployment?</p>
<p>PS. thanks for the good custom support and product -> we're
going to be upgrading to a PAID account now :)</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T00:13:45Z2015-01-13T00:13:45ZHow can I run my own powershell script AFTER the build step?<div><p>:) no prob - glad to be helpful!</p>
<p>Yes, you can check <code>$env:appveyor_repo_branch</code>
<a href=
"http://www.appveyor.com/docs/environment-variables">environment
variable</a>, something like:</p>
<pre>
<code>if($env:appveyor_repo_branch -eq 'master') {
# deploy
}</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T00:17:00Z2015-01-13T00:17:00ZHow can I run my own powershell script AFTER the build step?<div><p>Hmm! I was thinking about having the powershell script only ran
if the branch is <code>master</code>. Which means, leverage the
<em>branch only stuff</em> in the <code>appveyor.yml</code> file.
Not have the script run for every branch and I do the branch
specific checks in that.</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T00:20:42Z2015-01-13T00:20:42ZHow can I run my own powershell script AFTER the build step?<div><p>It could have been possible if there is "Script" deployment
provider, but it's not. It's just "script" instead of "providers"
infrastructure.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T00:34:03Z2015-01-13T00:34:03ZHow can I run my own powershell script AFTER the build step?<div><p>er - I don't get it :( so there's no way in an
<code>appveyor.yml</code> I can say -> <code>deploy_scipt</code>
=> when branch <code>master</code> run this <code>ps1</code>
?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T00:37:11Z2015-01-13T00:37:11ZHow can I run my own powershell script AFTER the build step?<div><p>Yep, but it's not a problem to check branch in that ps, right?
It's not much overhead.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T04:12:01Z2015-01-13T04:12:01ZHow can I run my own powershell script AFTER the build step?<div><p>true, but I would really prefer to do it via the
<code>yml</code> file if possible :(</p>
<p>any suggestions, please? :blush:</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T04:27:19Z2015-01-13T04:27:19ZHow can I run my own powershell script AFTER the build step?<div><p>It's just few lines:</p>
<pre>
<code>deploy_script:
- ps: >-
if($env:appveyor_repo_branch -eq 'master') {
# deploy
}</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T04:36:22Z2015-01-13T04:36:22ZHow can I run my own powershell script AFTER the build step?<div><p>How about something more like this...</p>
<pre>
<code>deploy_script:
branches:
only:
- master
/deployment/MyCustomDeployment.ps1</code>
</pre>
<p>otherwise, yeah .. i can just put that PS script inside my
ps-file. I was hoping to do some tricks in the <code>yml</code>
file to say: if <code>master</code> then run this script (to
deploy)</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-13T19:30:36Z2015-01-13T19:30:36ZHow can I run my own powershell script AFTER the build step?<div><p>I see. This probably could be solved by introducing new "Script"
deployment provider:</p>
<pre>
<code>deploy:
- provider: Script
script: so_something_here()
on:
branch: master</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:09:59Z2015-01-29T04:09:59ZHow can I run my own powershell script AFTER the build step?<div><p>Ok .. see how you have <code>script: do_something_here()</code>
...</p>
<p>is that the <em>entire</em> script? or just the name of the
script path (eg. my ps1 script file). ?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:12:58Z2015-01-29T04:12:58ZHow can I run my own powershell script AFTER the build step?<div><p>Good question. It's supposed to be just a script, not a path to
a file. Of course, you will be able to use dot-sourcing to run your
.ps1 though it depends on current directory.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:16:54Z2015-01-29T04:16:54ZHow can I run my own powershell script AFTER the build step?<div><p>example, please?</p>
<p>u mean something like this..</p>
<p><code>.\scripts\myScript.ps1</code> <-- that's a script, to
run a script?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:18:53Z2015-01-29T04:18:53ZHow can I run my own powershell script AFTER the build step?<div><p>Wait a second. This "script" provider doesn't exist yet. It's
just hypothetical provider we could implement...</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:28:28Z2015-01-29T04:28:28ZHow can I run my own powershell script AFTER the build step?<div><p>Oh - ok. i thought there was a <code>- provider: Script</code>
that currently exists and that it takes one option =>
<code>script: <the script code here></code>.</p>
<p>So, is this another item to the GH Issues list?</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:29:47Z2015-01-29T04:29:47ZHow can I run my own powershell script AFTER the build step?<div><p>Yeah, feel free to add the item</p>
<p>...but it's been so real - you almost believed :)</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:31:13Z2015-01-29T04:31:13ZHow can I run my own powershell script AFTER the build step?<div><p>The next AV "milestone" maybe be solely devoted to deployment,
so that might come into it.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:32:09Z2015-01-29T04:32:09ZHow can I run my own powershell script AFTER the build step?<div><p>Great! can i make an issue to remind me, if it gets implemented
(i know it's an <em>if</em>).</p></div>Pure Krometag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:33:43Z2015-01-29T04:33:43ZHow can I run my own powershell script AFTER the build step?<div><p>Sure.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/357519822015-01-29T04:36:38Z2015-01-29T04:36:38ZHow can I run my own powershell script AFTER the build step?<div><p><a href="https://github.com/appveyor/ci/issues/128">Done - issue
128</a> :)</p></div>Pure Krome