Using the CLI in a CI/CD environment to set the railway environment variables

innovioxPRO

7 months ago

I am trying to set up railway preview environments that link to supabase branches. This means that I need to set a custom POSTGRES_URL and SUPABASE_URL variable for each railway environment. I've enabled PR environments on railway, and I'm trying to set the environment variables using commands like:

```

railway variables -s $service -e "$repo-pr-$pr_number" --set "POSTGRES_URL=$url"

```

However, if I've set RAILWAY_API_TOKEN, I get "no linked project", and if I've set RAILWAY_TOKEN I get "Unauthorized. Please login with railway login". If I try to railway login --browserless I get Cannot login in non-interactive mode.

So, is there a way to get the railway variables command to work in a CI/CD pipeline?

Solved

1 Replies

7 months ago

Try using railway link --team <id> --project <id> --environment <id> --service <id>


Status changed to Awaiting User Response railway[bot] 7 months ago


Status changed to Solved brody 7 months ago