Support Forums

Branch deploy command

Hello, is there any option to configure branch deploy command just like the main build command in Netlify UI? We use different environment for branch deploys and we also have a monorepo with no subdirectories, so I can not use multiple netlify.tomls. My desired behaviour is to set build command for branch deploy for a specific site in Netlify UI. Another option I was looking for is to pass environment variable to a build command in netlify.toml file but I found in the docs it’s not possible.

Any ideas? Thanks!

That’s how it’s usually done. Could you specify what part of the docs said this just so we can be on the same page? If there’s some confusion or ambiguity in the docs, I can pass it on to the team.

But yeah, you can specify a different build command for branch deploys like mentioned here:

Monorepo consists of 4 projects with shared root files, including one netlify.toml. Project A has a build command npm build projectA -- -c production, project B has npm build projectB -- -c production and so on… This is easy to configure in Netlify UI since for each site I can specify different build command. However for branch deploys I can no longer specify project name in the command, I can only rely on one netlify.toml config. I want to configure commands in the same fashion but with different configuration ... -c develop.


Hi @AverageNetlifyBoi,

In that kind of a config, I’d recommend creating several .sh files and you can set your build command for each branch to build-branch.sh or something of that sort. In that you could write your shell command including environment variables.

1 Like

Thanks @hrishikesh! Instead of making shell scripts I ended up making node scripts which work just fine. Netlify builds projects correctly launching commands with env variables :smile:

node scripts/build.js

  `ng build ${process.env.PROJECT_NAME || ''} -c ${
    process.env.CONTEXT === 'production' ? 'production' : 'develop'
  {stdio: 'inherit'},
1 Like