1

I've already seen this question/answer here, but the solution isn't working for a Flutter project I'm working on.

Here's my yaml file:

image: cirrusci/flutter

variables:
before_script:
  - flutter channel beta
  - flutter upgrade
  
stages:
#  - build
  - test

#build:
#  stage: build
#  script:
#    - flutter build apk


unitTests:
  stage: test
  script:
   # - ls -la /opt/application/
   # - ls -la ~/
    - bash -c "echo \"$APP_VARS\" > ./cfg/env.json"
    - flutter test test/widget_test.dart

Which yielded a cannot access <filename/directory>: File or Directory Not Found error with both ls -la /opt/application/ and bash -c "echo \"$APP_VARS\" > ./cfg/env.json"

Her's the output from ls -la ~/:

$ ls -la ~/
total 72
drwxr-xr-x. 1 cirrus cirrus 4096 Jul  9 19:16 .
drwxr-xr-x. 1 root   root   4096 Mar  7  2018 ..
drwxr-xr-x. 1 cirrus cirrus 4096 Jul  9 19:17 .android
-rw-r--r--. 1 cirrus cirrus  220 May 15  2017 .bash_logout
-rw-r--r--. 1 cirrus cirrus 3526 May 15  2017 .bashrc
-rw-r--r--. 1 cirrus cirrus   24 Jul  9 19:16 .flutter
-rw-r--r--. 1 cirrus cirrus  675 May 15  2017 .profile
drwxr-xr-x. 1 cirrus cirrus 4096 Jul  9 19:16 .pub-cache
drwxr-xr-x. 1 cirrus cirrus 4096 Jul  9 19:16 sdks

My intent is to inject environment variables via the CI for use during testing (and hopefully deployment, although I haven't gotten that far yet).

Zoe
  • 27,060
  • 21
  • 118
  • 148
PujitM
  • 96
  • 1
  • 9

1 Answers1

0

The solution is two-part:

First, the /builds/**/cfg/ directory actually didn't exist. To fix this, you have two options-- do a mkdir or commit/push a file in the repo. I added an empty .gitignore to my cfg directory.

Then, that yielded a Permission Denied error. To solve this, I first tried to sudo my commands (which let me perform the mkdir mentioned above). When that didn't work, I did a chmod -R 777 /builds/, and that fixed my issue.

Going forward, I plan to use chmod [-R] 644 or chmod [-R] 755 instead and do a chmod +x on any files I need to run via a shell script.

I also moved my environment configuration script to the before_script: section in the gitlab YAML, but I don't believe that was necessary.

See for info on chmod.

PujitM
  • 96
  • 1
  • 9