How can I run my own powershell script AFTER the build step?

Pure Krome's Avatar

Pure Krome

12 Jan, 2015 07:25 AM

Hi :)

I've got my own powershell script for nuget deployment (and later on, I might include some other deployment stuff).

Is there a way I can run my own Powershell script if the script is a file that is part of my git repo?

eg. \build\build.ps1

cheers AV team :)

  1. 1 Posted by gep13 on 12 Jan, 2015 07:37 AM

    gep13's Avatar

    Hello,

    Is this:

    https://github.com/chocolatey/ChocolateyGUI/blob/develop/appveyor.y...

    What you are looking for?

    build.ps1 is a PowerShell script that is stored in my repository, and I run this as the first step in my build.

    Hope that helps!

    Gary

  2. 2 Posted by Pure Krome on 12 Jan, 2015 07:39 AM

    Pure Krome's Avatar

    Hi @gep13 - thanks heaps for looking at my question. I really appreciate it, mate.

    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!).

    so it's like .. after the tests all work, run this PS script.

  3. Support Staff 3 Posted by Feodor Fitsner on 12 Jan, 2015 05:46 PM

    Feodor Fitsner's Avatar

    You can use "Script" mode on Deployment tab or deploy_script in appveyor.yml.

  4. 4 Posted by Pure Krome on 13 Jan, 2015 12:11 AM

    Pure Krome's Avatar

    thanks @feodor :)

    one last question about this ... we :heart: using appveyor.yml scripts (instead of the ui).

    is there a way we can only run the deploy script when the git branch is master ? for everything else - there is no deploy script / no deployment?

    PS. thanks for the good custom support and product -> we're going to be upgrading to a PAID account now :)

  5. Support Staff 5 Posted by Feodor Fitsner on 13 Jan, 2015 12:13 AM

    Feodor Fitsner's Avatar

    :) no prob - glad to be helpful!

    Yes, you can check $env:appveyor_repo_branch environment variable, something like:

    if($env:appveyor_repo_branch -eq 'master') {
      # deploy
    }
    
  6. 6 Posted by Pure Krome on 13 Jan, 2015 12:17 AM

    Pure Krome's Avatar

    Hmm! I was thinking about having the powershell script only ran if the branch is master. Which means, leverage the branch only stuff in the appveyor.yml file. Not have the script run for every branch and I do the branch specific checks in that.

  7. Support Staff 7 Posted by Feodor Fitsner on 13 Jan, 2015 12:20 AM

    Feodor Fitsner's Avatar

    It could have been possible if there is "Script" deployment provider, but it's not. It's just "script" instead of "providers" infrastructure.

  8. 8 Posted by Pure Krome on 13 Jan, 2015 12:34 AM

    Pure Krome's Avatar

    er - I don't get it :( so there's no way in an appveyor.yml I can say -> deploy_scipt => when branch master run this ps1 ?

  9. Support Staff 9 Posted by Feodor Fitsner on 13 Jan, 2015 12:37 AM

    Feodor Fitsner's Avatar

    Yep, but it's not a problem to check branch in that ps, right? It's not much overhead.

  10. 10 Posted by Pure Krome on 13 Jan, 2015 04:12 AM

    Pure Krome's Avatar

    true, but I would really prefer to do it via the yml file if possible :(

    any suggestions, please? :blush:

  11. Support Staff 11 Posted by Feodor Fitsner on 13 Jan, 2015 04:27 AM

    Feodor Fitsner's Avatar

    It's just few lines:

    deploy_script:
    - ps: >-
        if($env:appveyor_repo_branch -eq 'master') {
          # deploy
        }
    
  12. 12 Posted by Pure Krome on 13 Jan, 2015 04:36 AM

    Pure Krome's Avatar

    How about something more like this...

    deploy_script:
       branches:
          only:
             - master
             /deployment/MyCustomDeployment.ps1
    

    otherwise, yeah .. i can just put that PS script inside my ps-file. I was hoping to do some tricks in the yml file to say: if master then run this script (to deploy)

  13. Support Staff 13 Posted by Feodor Fitsner on 13 Jan, 2015 07:30 PM

    Feodor Fitsner's Avatar

    I see. This probably could be solved by introducing new "Script" deployment provider:

    deploy:
    - provider: Script
      script: so_something_here()
      on:
        branch: master
    
  14. 14 Posted by Pure Krome on 29 Jan, 2015 04:09 AM

    Pure Krome's Avatar

    Ok .. see how you have script: do_something_here() ...

    is that the entire script? or just the name of the script path (eg. my ps1 script file). ?

  15. Support Staff 15 Posted by Feodor Fitsner on 29 Jan, 2015 04:12 AM

    Feodor Fitsner's Avatar

    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.

  16. 16 Posted by Pure Krome on 29 Jan, 2015 04:16 AM

    Pure Krome's Avatar

    example, please?

    u mean something like this..

    .\scripts\myScript.ps1 <-- that's a script, to run a script?

  17. Support Staff 17 Posted by Feodor Fitsner on 29 Jan, 2015 04:18 AM

    Feodor Fitsner's Avatar

    Wait a second. This "script" provider doesn't exist yet. It's just hypothetical provider we could implement...

  18. 18 Posted by Pure Krome on 29 Jan, 2015 04:28 AM

    Pure Krome's Avatar

    Oh - ok. i thought there was a - provider: Script that currently exists and that it takes one option => script: <the script code here>.

    So, is this another item to the GH Issues list?

  19. Support Staff 19 Posted by Feodor Fitsner on 29 Jan, 2015 04:29 AM

    Feodor Fitsner's Avatar

    Yeah, feel free to add the item

    ...but it's been so real - you almost believed :)

  20. Support Staff 20 Posted by Feodor Fitsner on 29 Jan, 2015 04:31 AM

    Feodor Fitsner's Avatar

    The next AV "milestone" maybe be solely devoted to deployment, so that might come into it.

  21. 21 Posted by Pure Krome on 29 Jan, 2015 04:32 AM

    Pure Krome's Avatar

    Great! can i make an issue to remind me, if it gets implemented (i know it's an if).

  22. Support Staff 22 Posted by Feodor Fitsner on 29 Jan, 2015 04:33 AM

    Feodor Fitsner's Avatar

    Sure.

  23. 23 Posted by Pure Krome on 29 Jan, 2015 04:36 AM

    Pure Krome's Avatar
  24. Pure Krome closed this discussion on 29 Jan, 2015 04:36 AM.

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

 

01 Oct, 2024 04:27 PM
26 Sep, 2024 03:49 PM
26 Sep, 2024 09:02 AM
25 Sep, 2024 07:07 PM
24 Sep, 2024 08:39 PM
24 Sep, 2024 06:47 AM