Im trying to automate my function deployment using gitlabs ci/cd pipeline. Im currently failing trying to use the appwrite cli to create a new deployment.
``` appwrite functions create-deployment --function-id $FUNCTION_ID --code "." --entrypoint "dist/main.js" --commands "npm i -g typescript && npm install && tsc" --activate true
No matter how I change the --code parameter I cannot get this command to work even when trying to execute it myself and not in the pipeline:
```
Error: File not found in payload
at _Client.<anonymous> (C:\Users\***\AppData\Roaming\npm\node_modules\appwrite-cli\dist\cli.cjs:110410:15)
at Generator.next (<anonymous>)
at C:\Users\***\AppData\Roaming\npm\node_modules\appwrite-cli\dist\cli.cjs:109848:67
at new Promise (<anonymous>)
at __awaiter (C:\Users\***\AppData\Roaming\npm\node_modules\appwrite-cli\dist\cli.cjs:109830:10)
at _Client.chunkedUpload (C:\Users\***\AppData\Roaming\npm\node_modules\appwrite-cli\dist\cli.cjs:110407:12)
at Functions.createDeployment (C:\Users\***\AppData\Roaming\npm\node_modules\appwrite-cli\dist\cli.cjs:116010:24)
at C:\Users\***\AppData\Roaming\npm\node_modules\appwrite-cli\dist\cli.cjs:143588:111
```
What does that error mean? Is it even related to the --code parameter?
Any help on this?
have you tried using an appwrite.json file and appwrite push functions -f <function-id>
do i put the appwrite.json in the root of my repo for it to work? what exactly do I need to have inside the appwrite.json?
but still even if using a json file works shouldnt the create-deployment one work?
and I've noticed that the push command requires an input after executing which is very bad for automating
if you give it the params it needs it doesn't do the interactive cli part
no it still does
it asks if i want it to create a deployment
why isnt the --force option listed in the help?
couldn't tell ya /:
well ty anyway it worked
just messing around with typescript now to get the function to actually function
For anyone wanting to do this in the future: ```yaml stages:
- build
- deploy
build-function: stage: build image: node:lts-alpine only: - main script: - npm install -g typescript - npm install - tsc artifacts: paths: - dist/ - package.json - appwrite.config.json expire_in: 1 hour
deploy-function: stage: deploy image: node:lts-alpine dependencies: - build-function only: - main before_script: - npm install -g appwrite-cli - appwrite client --endpoint $APPWRITE_ENDPOINT --project-id $APPWRITE_PROJECT_ID --key $APPWRITE_API_KEY script: - appwrite push function --function-id $FUNCTION_ID --force ```
You have to set all the variables in your gitlab instance/repo ci/cd variables as well as have a appwrite.config.json containing the following:
```json { "functions": [ { "$id": "<Function Id here>", "name": "<Function Name Here>", "runtime": "node-16.0", "specification": "s-1vcpu-512mb", "execute": [], "scopes": [], "events": [], "schedule": "", "timeout": 15, "enabled": true, "logging": true, "entrypoint": "dist/main.js", "commands": "npm install", "ignore": ["node_modules", ".npm"], "path": "." } ] }
(you may need to tweak some of the values to your specific function)
[SOLVED] Gitlab function automation
Edit: when running the ci/cd pipeline when the function has not yet been created in the appwrite console, the deploy-function job will be marked as successful but will not actually have pushed the function. just re-run the deploy stage and it will work without issue on all future jobs
Recommended threads
- Error upgrading from 1.8.1 to 1.9.0
DO Self-hosted server failed to upgrade with this error "Error response from daemon: client version 1.52 is too new. Maximum supported API version is 1.42". U...
- MariaDB refuses to connect to appwrite
Earlier, I tried updating my Appwrite version from 18.1.x to the latest release because my Flutter package required it to function properly. I used the official...
- executeFunction intermittently throws Fo...
Environment: Flutter app using the Appwrite Flutter SDK, calling executeFunction for [describe endpoint, e.g. live-stream-related function]. *Description*: Int...