Ionic Appflow - package.json and shell scripts

#1

In the Build Environments docs for Appflow (https://ionicframework.com/docs/appflow/environments/#custom-environments) there is an example that uses a custom shell script to read the branch and triggers a custom build:

package.json

"scripts": {
    "build": "./mybuild.sh",
},

mybuild.sh

#!/bin/bash
if [ "$CI_GIT_REF" = "master" ]; then
    npx ionic build --prod
else
    npx ionic build
fi

I am trying this exact code and seem to get a permission error when attempting to package the build. Wondering what deal is or if I am doing something wrong. Thanks.

> ./mybuild.sh

sh: ./mybuild.sh: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! vipcrowd@1.0.0 build: `./mybuild.sh`
npm ERR! Exit status 126
npm ERR! 
npm ERR! Failed at the vipcrowd@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ionic/.npm/_logs/2019-01-04T22_29_55_359Z-debug.log

EDIT: My end goal is to use different build scripts based on the env and eventually have different cordova plugin variables based on env. So either a fix to this or alternate method would help greatly.

1 Like
#2

I am seeing the exact same thing. Does anyone have any ideas?

#3

How and where did you create that file? On Linux/macOS and set it to executable? Or on Windows where this doesn’t matter?

Also, did you see this note on that documentation page?

Note: This feature is only available on our Growth plans and above.

#4

So, for an update, I stopped trying to use this implementation because I could not get it to work. Instead I was able to change the way we used certain plugins to not be so heavily reliable on the build script. That being said, at this time and at the time of the original post we were paying for our Growth plan. I was also operating on macOS Mojave. As far as setting it to executable I am not positive but I am pretty sure it was running locally just fine

1 Like
#5

Windows 10 for me. I placed it at the same level as package.json.
I have a growth plan

#6

Answer hopefully is here.


Worked for me.