Access build folder in Xcode Server CI bot run (env variables?)

前端 未结 3 1345
名媛妹妹
名媛妹妹 2020-12-29 10:05

I need to access the folder that is created dynamically during each bot integration. On one of the run it is something like this -

/Library/Developer

相关标签:
3条回答
  • 2020-12-29 10:30

    I'm not familiar with Xcode Server but generally Unix/CI systems when export environment variables they only export it to the current session.

    If you want to set an environment variable persistently you have to set it in an initializer file like ~/.bash_profile or ~/.bashrc so it always gets set/loaded when a shell session starts (ex: when you log in with Terminal - the exact file depends on what kind of shell you start).

    It wouldn't make much sense to export these persistently either, because in that case if you run different integrations these would simply overwrite each others exported environment variables (they would set the same environment variables).

    That's why the systems which communicate through environment variables usually don't write the variables into persistent initialiser file rather just export the variables. With export the variable is accessible from the process which exports it and from the child processes the process starts.

    For example in a bash script if you export a variable you can access it from the bash script after the export and from any command/program you start from the bash script, but when the bash script finishes the environment won't be accessible anymore.

    edit Just to clarify it a bit: You should be able to access these environment variables from a post trigger script, run by Xcode Server but you most likely won't be able to access these from your Terminal/command line.

    Also where can I find the list of variables created by this CI system?

    You can print all the available environment variables with the env command. In a bash script simply type env in a new line like this:

    #!/bin/bash
    env
    

    This will print all the available environment variables (not just the ones defined by Xcode Server!) - you can simply pipe it to a file for inspection if you want to, like this:

    #!/bin/bash
    env > $HOME/envinspect.txt
    

    After this script runs you can simply open the envinspect.txt file in the user's home folder.

    0 讨论(0)
  • 2020-12-29 10:32

    @Viktor is correct, these variables only exist during their respective sessions. @Pappy gave a great list of those variables.

    They can be used in a script like so:

    IPA_PATH="${XCS_OUTPUT_DIR}/${XCS_BOT_NAME}.ipa"
    echo $IPA_PATH
    
    0 讨论(0)
  • 2020-12-29 10:42

    I have been echoing set to the bot log, the first line of my bot script is simply

    set   
    

    When you view the log after the integration is complete it will be in your trigger output.

    XCS_ANALYZER_WARNING_CHANGE=0
    XCS_ANALYZER_WARNING_COUNT=0
    XCS_ARCHIVE=/Library/Developer/XcodeServer/Integrations/Integration-76eb5292bd7eff1bfe4160670c2d4576/Archive.xcarchive
    XCS_BOT_ID=4f7c7e65532389e2a741d29758466c18
    XCS_BOT_NAME='Reader'
    XCS_BOT_TINY_ID=00B0A7D
    XCS_ERROR_CHANGE=0
    XCS_ERROR_COUNT=0
    XCS_INTEGRATION_ID=76eb5292bd7eff1bfe4160670c2d4576
    XCS_INTEGRATION_NUMBER=15
    XCS_INTEGRATION_RESULT=warnings
    XCS_INTEGRATION_TINY_ID=FF39BC2
    XCS_OUTPUT_DIR=/Library/Developer/XcodeServer/Integrations/Integration-76eb5292bd7eff1bfe4160670c2d4576
    XCS_PRODUCT='Reader.ipa'
    XCS_SOURCE_DIR=/Library/Developer/XcodeServer/Integrations/Caches/4f7c7e65532389e2a741d29758466c18/Source
    XCS_TESTS_CHANGE=0
    XCS_TESTS_COUNT=0
    XCS_TEST_FAILURE_CHANGE=0
    XCS_TEST_FAILURE_COUNT=0
    XCS_WARNING_CHANGE=36
    XCS_WARNING_COUNT=36
    
    0 讨论(0)
提交回复
热议问题