Sunday, February 24, 2013

Using Teamcity + ANT to deploy Yii website

Over the last couple of weeks, I've deferred a bit from my normal .NET stuff and I'm working on some PHP projects within the company. I set up a website that offers an API to our partners and I've decided to go with Yii, because it seems quite popular at the moment.

Getting into Yii is very easy - there are great 'hello world' tutorials out there and after that it's really simple to get a hang of. Anyway - I set up deployment using our Teamcity server using an ANT script. 

Here's the steps of the ANT script:

  1. Overwrite the main.config file by my custom main.live.config file - containing db connection to the production DB etc. 
  2. Update the main.php configuration file and replacing some version and build numbers, so that I can display rev. ####, build ### at the bottom.
  3. Zip the checkout folder
  4. Upload the zipped file over ssh
  5. Remote unzip the file

Deployment takes 30 seconds here . Check it out:



  
  


  
    
    
    
  


  
    
    
    
    
      
    
    
    
  


  
    
    
      
    
    
  


    
    
    
    
  

  
    
    
    
  

  
    
    
    
    


I see that the code formatter is messing up the XML code - so just copy pasting won't work I'm affraid. Echo is an empty XML node of couse - like <echo .... /> .
Anyway - for us this is a great way of deploying our Yii site quickly, with updated version numbers and custom production configuration.

No comments:

Post a Comment