github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0144.yml (about)

     1  doc_meta: |
     2    folder: usage
     3    title: working directory
     4    head: |
     5      By default, you will be using current working directory for an execution of your task
     6  
     7      Sometimes, we need a protected way or simly we need a jailed execution to where the task up.yml is located, in this case, we could config the working directory to be the refdir and in this case the refdir is out side of current directory
     8  
     9    sections:
    10      - title: How it works
    11        content: |
    12          By default, the WorkDir setting is "cwd", which is the current working directory you execute the up command
    13  
    14          There are two ways doing it:
    15  
    16          * You can configure it in the upconfig.yml
    17          ```
    18          version: 1.0.0
    19          Verbose: v
    20          MaxCallLayers: 8
    21          RefDir: .
    22          WorkDir: refdir      -> use "refdir" to dictate the execution working directory will be in the refdir instead of current work dir
    23          TaskFile: up.yml
    24          ConfigDir: .
    25          ConfigFile: upconfig.yml
    26          ```
    27  
    28          * You can use cmd arg in CLI to specify that you want it to be refdir
    29  
    30          ```
    31            -w, --workdir=WORKDIR        working directory: cwd | refdir
    32  
    33            eg:
    34            up ngo task -d ./tests/functests -t wip.yml -i dev --configdir=./tests/functests -w refdir
    35          ```
    36  
    37      - title: Application using current directory as work directory
    38        content: |
    39          Normally, if you intend to do project based work, then you will need to use the default setting: cwd - current work directory as the working directory.
    40  
    41          In this case, you cd to the project directory, all the directories in your up.yml will be reletive path to your project directory
    42  
    43      - title: Application using refdir
    44        content: |
    45          If the up.yml tasks are wrapped as a service to do something system wide and not relevent to your specific project, all the changes made in the task are confined within the refdir, than the WorkDir should be refdir
    46  
    47          For example, you could use below alias: install_apps to install and update all your softwares, this task will manage to install all defined softwares and if it requires to caches some files and temp directories, it will put them into the refdir
    48  
    49          ```
    50          alias install_apps='up ngo task -d /myapps/install_all_required_softwards -w refdir'
    51          ```
    52  
    53          So, when you consider publish your own task(s) for other people to use as a standalone tool/cli cmd, you should use this setting
    54  
    55      - title: Demo
    56        log: yes
    57  
    58  tasks:
    59    -
    60      name: task
    61      desc: main entry
    62      task:
    63        -
    64          func: shell
    65          desc: main job
    66          do:
    67            - pwd