Answers.Body: <p>Got this working with help from Udo's answer.
  For anyone using TeamCity who would find this useful I'll share my setup for it.</p>
  
  <p>First I deploy the site from a Git VCS root and use the 'SSH Upload' runner type</p>
  
  <p>Then I was trying to set up the sync command through an 'SSH Exec' runner but that didn't seem to work, not sure what the issue was with it so might be able to set it up that way still.
  The working method is the 'Command Line' runner, set it to run a custom script with the code provided by Udo, <code>ssh {user}@{host} {file_path}/craft project-config/sync</code> the command line is run from the TeamCity agent server not the production server like the SSH Exec runner is meant to.</p>
  
  <p>Additional note to make sure the craft file is executable, if not you will need to do <code>chmod a+x craft</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-22T12:54:03.767Z
Answers.LastActivityDate: 2019-08-22T12:54:03.767Z
Answers.UserDisplayName: WillBV
Answers.Body: <p>This sounds like the working directory where you are executing the command isn't what you think it is, for example maybe the script is executing the command in / (root) instead of the craft directory.</p>
  
  <p>To run you the project config sync, try adding a step like this to your build setup:</p>
  
  <p>ssh $PRODUCTION_USER@$PRODUCTION_HOST "$PRODUCTION_PATH/craft project-config/sync"</p>
  
  <p>This will remotely run the sync on the live server.</p>
  
  <p>You will need to have ssh keys set up in your build setup for the ssh command to be able to authenticate, and replace the $VARIABLES with your actual values (or define them somewhere in the build setup if that is possible in TeamCity).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-22T10:54:23.663Z
Answers.LastActivityDate: 2019-08-22T10:54:23.663Z
Answers.UserDisplayName: Udo
Body: <p>I have a Craft CMS site set up that deploys through TeamCity and am trying to set up a build step to auto run "./craft project-config/sync".</p>
  
  <p>I keep getting an error saying the file can't be found, I've changed the paths a dozen times to try and get it right but no luck.
  Has anyone had experience with this or able to advise how to set this up?</p>
  
Tags: <craft3><config><craft-features><deployment>
Title: Deploying and syncing project.yaml
ThreadText: # Deploying and syncing project.yaml
  
  (Asked by: username_0 on 2019-08-22)
  
  I have a Craft CMS site set up that deploys through TeamCity and am trying to set up a build step to auto run "./craft project-config/sync".
  
  I keep getting an error saying the file can't be found, I've changed the paths a dozen times to try and get it right but no luck.
  Has anyone had experience with this or able to advise how to set this up?
  
  **Tags:** craft3, config, craft-features, deployment
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-08-22. Score: 2 | Accepted answer
  
  Got this working with help from Udo's answer.
  For anyone using TeamCity who would find this useful I'll share my setup for it.
  
  First I deploy the site from a Git VCS root and use the 'SSH Upload' runner type
  
  Then I was trying to set up the sync command through an 'SSH Exec' runner but that didn't seem to work, not sure what the issue was with it so might be able to set it up that way still.
  The working method is the 'Command Line' runner, set it to run a custom script with the code provided by Udo, `ssh {user}@{host} {file_path}/craft project-config/sync` the command line is run from the TeamCity agent server not the production server like the SSH Exec runner is meant to.
  
  Additional note to make sure the craft file is executable, if not you will need to do `chmod a+x craft`
  
  
  ---
  
  ### Answer by username_1 on 2019-08-22. Score: 1
  
  This sounds like the working directory where you are executing the command isn't what you think it is, for example maybe the script is executing the command in / (root) instead of the craft directory.
  
  To run you the project config sync, try adding a step like this to your build setup:
  
  ssh $PRODUCTION\_USER@$PRODUCTION\_HOST "$PRODUCTION\_PATH/craft project-config/sync"
  
  This will remotely run the sync on the live server.
  
  You will need to have ssh keys set up in your build setup for the ssh command to be able to authenticate, and replace the $VARIABLES with your actual values (or define them somewhere in the build setup if that is possible in TeamCity).
  
  
  ---
  
  