multi-line PowerShell scripts

Abel Salgado Romero's Avatar

Abel Salgado Romero

Dec 23, 2014 @ 11:55 AM

Hi,
I'm struggling to make a simple PS script to install some package under some conditions but i'm not able to get the syntax right for a multi-line execution. The only documentation found is here http://www.appveyor.com/docs/build-configuration, and it's of not much use :%
I've tried several things and nothing works, I always end up with a message like this one:
'XXX' is not recognized as an internal or external command.

Thanks,

  1. Support Staff 1 Posted by Feodor Fitsner on Dec 23, 2014 @ 04:27 PM

    Feodor Fitsner's Avatar

    How does you PS script look right now?

    -Feodor

  2. 2 Posted by Abel Salgado Ro... on Dec 23, 2014 @ 04:47 PM

    Abel Salgado Romero's Avatar

    I'd like to install maven and cache the installation. To do that, I'd like to check if the installation folder already exiats during installation, but I cannot get the syntax right.
    Here is what i'm trying to do:

    install:
      - ps:
      - $MVNDIR = 'C:\bin\apache-maven-3.2.3\'
      - if(!(Test-Path -Path $MVNDIR )){
      - cinst maven
      -}
      - cmd: SET PATH=%JAVA_HOME%\bin;%PATH:C:\Ruby193\bin;=%
      - cmd: java -version
    # Note: env variables are not correctly updated by choco (setting it manually)
      - cmd: SET PATH=C:\bin\apache-maven-3.2.3\bin;%PATH%
      - cmd: mvn --version
    build_script:
      - mvn package
    test_script:
      - mvn test
    cache:
      - C:\bin\apache-maven-3.2.3\

  3. Support Staff 3 Posted by Feodor Fitsner on Dec 23, 2014 @ 04:57 PM

    Feodor Fitsner's Avatar

    I see. Try this:

    install:
    - ps: >-
        $MVNDIR = 'C:\bin\apache-maven-3.2.3\'
        if(!(Test-Path -Path $MVNDIR )){
          cinst maven
        }
    - cmd: SET PATH=%JAVA_HOME%\bin;%PATH:C:\Ruby193\bin;=% 
    ...
    
  4. 4 Posted by Abel Salgado Ro... on Dec 23, 2014 @ 06:26 PM

    Abel Salgado Romero's Avatar

    It works now, thanks :)
    Dunno why I had to add a line brake after the $MVNDIR line, but it's working nicely now.
    Here is the file in case some else needs it
    https://github.com/abelsromero/asciidoctor-maven-plugin/blob/master/appveyor.yml

  5. Support Staff 5 Posted by Feodor Fitsner on Dec 23, 2014 @ 06:28 PM

    Feodor Fitsner's Avatar

    Great, thanks for the update!

  6. Ilya Finkelshteyn closed this discussion on Aug 25, 2018 @ 01:52 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