Exclude commands from PR build

kyle.spearrin's Avatar

kyle.spearrin

11 Feb, 2017 06:23 AM

I have some commands that rely on environment variables to execute. For example:

    after_build:
      ..
      - secure-file\tools\secure-file -decrypt src\myfile.txt.enc -secret %dec_secret%
      ..

However, I do not want this to run on PR builds because the environment variables are not available. How do I enable certain commands to not run on PR builds?

  1. Support Staff 1 Posted by Feodor Fitsner on 11 Feb, 2017 11:11 PM

    Feodor Fitsner's Avatar

    You can use something like:

    - IF DEFINED dec_secret secure-file\tools\secure-file -decrypt src\myfile.txt.enc -secret %dec_secret%
    
  2. 2 Posted by kyle.spearrin on 11 Feb, 2017 11:46 PM

    kyle.spearrin's Avatar

    Is this possible with other parts of the config file as well? For example, I only have an artifact to attach if the environment variables are set in an earlier part of the build (env vars are needed to produce the artifact) so I imagine this will fail if the file does not exist?

    artifacts:
      - path: com.package-%APPVEYOR_BUILD_NUMBER%.apk

  3. 3 Posted by Ilya Finkelshte... on 13 Feb, 2017 09:26 AM

    Ilya Finkelshteyn's Avatar

    Hi Kyle,

    Build will not fail, it will just write warning like No artifacts found matching 'com.package-123.apk' path assuming 123 is build number.

    Ilya.

  4. 4 Posted by kyle.spearrin on 14 Feb, 2017 03:44 AM

    kyle.spearrin's Avatar

    Great! Last question to wrap this one up:

    What does the syntax look like for powershell command? Something like this?

    after_build:
      - ps: IF($env:myvar) copy-item file1.txt .\file2-$($env:myvar).txt

  5. Support Staff 5 Posted by Feodor Fitsner on 14 Feb, 2017 04:20 AM

    Feodor Fitsner's Avatar

    Correct.

  6. 6 Posted by kyle.spearrin on 14 Feb, 2017 04:21 AM

    kyle.spearrin's Avatar

    Thanks all! This is now resolved.

  7. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:14 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