Wednesday, February 6, 2013

Steps to checkout and commit a WSO2 Appfactory GIT application.

WSO2 App Factory is a platform for managed application development for the entire lifecycle of applications. Supporting you from cradle to grave, you can create, develop, test, deploy to production and retire applications with a single click. Applications can be web applications to mobile apps that require any type of middleware to run on including even non-Java and non-WSO2 technologies.
For more information : 
 http://blog.cobia.net/cobiacomm/2012/04/16/what-is-wso2-appfactory/

Following steps will be useful for a user who is using git as the repository and to checkout the code of the created application and the steps till it is committed.

For The Ubuntu Environment

  1. First step should be installing GIT in to your machine. Therefore the following command should be executed.
    Command : $ sudo apt-get install git

  2. Check whether GIT is available in your machine now.
    Command : $ git init
    Response : Initialized empty Git repository in /home/../.git/

  3. Create a folder to archive the Git projects in to one location in your repository.
    Command : $ mkdir GITPROJECTS

  4. Add all the Git projects in to your repository by the following command.
    Command : GITPROJECTS$ git add .

  5. To get the GIT to Accept the certificate, type the following command.
    Command : GITPROJECTS$ export GIT_SSL_NO_VERIFY=1
    On Windows : (Right click on My Computer -> Properties -> Advanced System settings -> Environment Variables
    Add variable GIT_SSL_NO_VERIFY with value 1)

  6. To clone the particular project in to your repository, copy the (Clone/Check out) repository URL in the application Dashboard or the Repository page of the App Factory. (Only if you have developer or App Owner rights)
         Command : GITPROJECTS$ git clone https://git.appfactorypreview.wso2.com/git/MyApp.git
         Response : Cloning into 'MyApp'...
         Username for 'https://git.appfactorypreview.wso2.com': <Developer's username> e.g., ushani@wso2.com
         Password for 'https://ushani@wso2.com@git.appfactorypreview.wso2.com': *****
         remote: Counting objects: 23, done
         remote: Finding sources: 100% (23/23)
         remote: Getting sizes: 100% (14/14)
         remote: Compressing objects: 100% (13/13)
         remote: Total 23 (delta 4), reused 23 (delta 4)
         Unpacking objects: 100% (23/23), done.

  1. List down and check the project
    Command : GITPROJECTS$ ls
    Response : MyApp

  2. Go inside the project and check for the available branches in the repository
    Command : GITPROJECTS$ cd MyApp
    Command : MyApp$ git branch -r
    Response : origin/1.0.0
    origin/2.0.0
    origin/3.0.0
    origin/4.0.0
    origin/HEAD -> origin/master
    origin/master 

  3. To list down the local branches that you have, following command can be executed
    Command : MyApp$ git branch
    Response : * master
(* master means the trunk. The branch that you are currently working on will have a star next to it and if you have coloring turned on, will show the current branch in green)

  1. To create other branches in the local repository, following command should be executed.
    Command : MyApp$ git branch <version name>
                e.g, git branch 1.0.0 
                 
  2. Now check the created branch
    Command : MyApp$ git branch
    Response : 1.0.0
          * master

  3. To switch to 1.0.0, following command should be executed to check out the relevant code in to your local repository
    Command : MyApp$ git checkout 1.0.0
    Response : Switched to branch '1.0.0'
(*Steps 10 and 11 can be executed together by executing “git checkout -b 1.0.0”. Then it will branch out 1.0.0 and switch to it. When you type checkout and give the branch name, the source code you have in your local repository will be the given version's source code that is in the App Factory repository. If you type “git branch” you should see the 11th step response)

  1. Now it is the coding time. You can import your project in to a specific IDE (E.g., Eclipse) and do coding.

  2. You can install a toolkit which helps you to show the changes you have done in to your code by installing GITK (Generalized Interface Toolkit - GITK). To install, following command can be executed.
    Command : Downloads$ sudo apt-get install gitk
    (This step can be done as the 2nd step after installing git in your machine. For more reference on git, follow this manual on https://www.kernel.org/pub/software/scm/git/docs/gitk.html)

  3. After doing code level changes, when you type the following command, GIT window will be opened with the changes or mentioning the about the changes that you have to commit
    Command : MyApp$ gitk 
     
  4. By executing the following command you can view the changes in you terminal.
    Command : MyApp$ git diff

  5. To add all the changes following command should be executed.
    Command : MyApp$ git add *

  6. Using gitk, you can view the changes and the difference in a graphical interface by selecting the particular file or folder. (Use the manual in step 14 for more information)

  7. Now it is the time to commit if your build passes locally. Execute the following command to commit your code. Command : MyApp$ git commit -am "Committing changes"
    Response : ([1.0.0 9b736e4] Committing changes
    Committer: ushani <ushani@ushani...>
    Your name and email address were configured automatically based
    on your username and hostname. Please check that they are accurate.
    You can suppress this message by setting them explicitly:
    git config --global user.name "Your Name"
    git config --global user.email you@example.com
    After doing this, you may fix the identity used for this commit with:
    git commit --amend --reset-author
    1 file changed, 2 insertions(+) )
    (For more information on git commits, rollbacks, applying etc, use the following guide. http://gitref.org/basic/)


  8. To push the commits, execute, git push <remote>, where <remote> is the current branch’s remote (or origin, if no remote is configured for the current branch.
    Command : MyApp$ git push origin remotes/origin/1.0.0

    (For more information on git commits, rollbacks, applying etc, use the following guide. http://www.kernel.org/pub/software/scm/git/docs/git-push.html )
    Response :Username for 'https://git.appfactorypreview.wso2.com': ushani@wso2.com
    Password for 'https://ushani@wso2.com@git.appfactorypreview.wso2.com': *****
    remote: Updating references: 100% (1/1)
    To https://git.appfactorypreview.wso2.com/git/MyApp.git
    * [new branch] origin/1.0.0 -> origin/1.0.0

  9. You can pull the committed code by executing the following command to verify the changes are committed. (But not necessary)
    Command : MyApp$ git pull origin remotes/origin/1.0.0 
     
  10. Now in App factory, if you have selected the Auto Build and Auto Deploy options for the particular branch version, once you do a commit, within 6 minutes the latest version should be built and deployed in the cloud. Otherwise you have to manually build and deploy it.

  11. Now you can click on the Launch link and see it in the Developer's environment and if it is fine to go ahead, you can promote it to testing stage by the Governance tab.

No comments:

Post a Comment