== Pulling, contributing, and pushing the OpenDaylight controller code using the GIT CLI The OpenDaylight project has a number of sub-projects under it. Each of these sub-projects have their own repositories in Gerrit. You can use either Git or Eclipse to contribute to the code for any of these sub-projects. For a list of OpenDaylight projects, see https://wiki.opendaylight.org/view/Main_Page#Projects[OpenDaylight Projects]. === Prerequisites for contributing code to the OpenDaylight project * You have created a Gerrit account and have registered a public-private key pair for using Git over SSH. For more information, see https://wiki.opendaylight.org/view/OpenDaylight_Controller:Gerrit_Setup[Getting started with Git and Gerrit]. * Your credentials (name, email) are configured properly in Git by running the following command: [literal] git config --global user.name "John Doe" git config --global user.email johndoe@example.com * You are familiar with Git commands. For more information, see https://wiki.opendaylight.org/view/GIT_Cheat_Sheet[GIT Cheat Sheet]. * You have installed Maven in your system. For more information about Maven, see http://maven.apache.org/[Apache Maven Project]. To install Maven using *yum* as the package manager, run the command: [literal] sudo yum install maven * You have installed Java 1.7+ in your system, including the JDK. For more information, see http://www.oracle.com/technetwork/java/javase/downloads/index.html[Java SE Downloads]. To install Java using *yum* as the package manager, run the command: [literal] sudo yum install java-1.7.0-openjdk The output must match the sample message given below: [literal] [~]$ java -version java version "1.7.0_55" OpenJDK Runtime Environment (fedora-2.4.7.0.fc20-x86_64 u55-b13) OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode) NOTE: For more information on setting up the environment for developing code for OpenDaylight, see https://wiki.opendaylight.org/view/GettingStarted:Development_Environment_Setup[Getting Started with the Development Environment]. NOTE: You may also use the git review tool to push your changes to the repository. For more information, see https://wiki.opendaylight.org/view/Git-review_Workflow[Git Review Workflow] === Building the OpenDaylight code Run the following command: [literal] cd opendaylight/distribution/opendaylight/ mvn clean install === Troubleshooting Maven issues * The Maven build may run out of PermGen depending on the number of artifacts built. This issue usually occurs when building the opendaylight distribution. To resolve the issue, increase the PermGens. Set the value of the environment variable as follows: [literal] MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m" /* syntax for setting varies on the OS used by the build machine.*/ * If you receive a Maven error when building northbound integration tests, you can skip building the tests by running the following command: [literal] mvn clean install -DskipTests /* instead of "mvn clean install" */ * If you have issues with maven needing a proxy, see http://www.mkyong.com/maven/how-to-enable-proxy-setting-in-maven/[How To Enable Proxy Setting In Maven]. === Running the OpenDaylight controller . Run the following command: [literal] cd controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-osgipackage/opendaylight/ ./run.sh [start=2] . Go to *http://localhost:8080/* and login in with username *admin* and password *admin*. NOTE: For more information in running the controller, see the Installation Guide. === Pulling the code from the remote repository To pull the latest changes from the Git repository, run the following command: [literal] git pull ssh://@git.opendaylight.org:29418/controller.git HEAD:refs/for/master === Committing the code using the Developer Certificate of Origin Your contributions to the OpenDaylight code is accepted only if you attach the http://elinux.org/Developer_Certificate_Of_Origin[Developer Certificate Of Origin]. The certificate implies that you have made the changes and the work was done as part of an open-source license. To attach the certificate, run the command below: [literal] git commit --signoff Or [literal] git commit -s You are prompted for a commit message. If you are fixing an issue from Bugzilla, you can add the information to your commit message and it will get linked from Gerrit. [literal] Fix for bug 2. Signed-off-by: Ed Warnicke # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: README # If you wish to add the signoff to the commit message on your every commit without the need to specify *--s* or *--signoff*, add the following lines in the end of *.git/hooks/commit-msg*, after the line *"add_ChangeId"*: [literal] SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" === Pushing the code * To push your changes to the repository, run the command below: [literal] git push ssh://@git.opendaylight.org:29418/controller.git HEAD:refs/for/master To push a draft that is not to be merged, run the command below: [literal] git push ssh://@git.opendaylight.org:29418/controller.git HEAD:refs/drafts/master A message similar to the following is displayed: [literal] remote: Resolving deltas: 100% (2/2) remote: Processing changes: new: 1, refs: 1, done remote: remote: New Changes: remote: http://git.opendaylight.org/gerrit/64 remote: === Reviewing and merging the code . Copy the link from the display message of your git push command and run it in a browser. The link must display that the code is verified by the Jenkins Controller User and a link is provided to the Jenkins build. See the figure below. image::Jenkins_message.jpg[title="Code Changes in Gerrit", alt="Code Changes in Gerrit"] [start=2] . After your code is reviewed and submitted by a committer, it will be merged into the authoritative repository. See the figure below. image::merged_code.jpg[title="Merging Code in Gerrit", alt="Merging Code in Gerrit"] === Troubleshooting blocked port 29418 There have been reports that many firewalls may block port 29418. To resolve the issue, use HTTP to clone the repository. [literal] git clone https://@git.opendaylight.org/gerrit/p/controller.git You are prompted for the password you generated in https://wiki.opendaylight.org/view/OpenDaylight_Controller:Setting_up_HTTP_in_Gerrit[Setting up HTTP in Gerrit].