Creating an online service – Using cloudbees for Continuous Deployment with Basic Service based projects
The previous post discussed getting the basic service application to your local development environment and getting it setup. In this post I’ll describe the process of setting up cloudbees for working with a Basic Service like project, so we can close the loop all the way to production.
We’ll be using cloudbees’ SEND-GRID services to send emails (registration verification process uses it to send a confirmation email), so before going further, go into cloudbees->services, and activate SendGrid. You can pick the free account for now.
Before creating a new git repository in cloudbees, we need to do some housekeeping in Git. Git has a file called .gitignore, which helps tell git what you don’t want to monitor and commit. At the very least, add the following entry:
to the .gitignore file (create the file if it does not exist in your main project directory). This will prevent you from accidentally checking in your targe directory (which is built automatically by the cloudbees CI environment). Now that we have this covered, it’s time to get started.
Setting up a git repository in cloudbees is easy, just pick Repositories->create new repository, give it a name and pick Git as your repository type, and click enter.
Once that repository is done, you need to connect your local repository to the cloudbees one so you can push your code. After creating your repository, you will see some helpful short examples of how to connect to cloudbees (just below the details paragraph). Pick “Migrating to your cloudbees repository”, and follow the steps. Don’t pull/push from legacy, just use the remote rm command to remove the old repository. Alternatively, you can delete the .git directory and start a new git repository from scratch (without the basicservice history). Just follow the “committing an existing project to git” cloudbees instructions to do that instead.
You repository should now be about 0.6MB, and contain the project files.
Once you’ve setup your repository, the next thing you need to do is setup a Build configuration.
Before going to builds, open your repository details, and copy the uri starting with ssh:// (you will need it shortly)
Hit builds, and create a New Job.
Give it a name, and pick “Build a maven 2/3 project”. Hit next.
Mark “one click deployment”, select “Oracle 1.7 latest” as your JDK, unclick “restrict where this project can run”, select “git” as your repository.
In the git url paste the ssh:// url you copied earlier. Put two stars (**) in the branches to build input field.
In build->goals and options put: clean install
In post steps, select “run only if build succeeds”, in the build settings, mark the email notification and add your email so you get notified of checkins and builds.
Pick “abort the build if it’s stuck” and pick whatever makes sense to you (I chose elastic)
Add a post-build-action and deploy-to-cloudbees, add web application and pick “maven artifact selection”. Add an application id (your project name is fine). Click “Advanced”, and enter production in the “Environment” field.
Don’t worry about the “not found” warning, click save.
Click build Now, and when an available worker is ready your project will start building. Click the running build and then console Output to see the process in action. When the build is complete, you should see something like:
[cloudbees-deployer] Deployed to application id your_account/your_project [cloudbees-deployer] Can be accessed at http://yourproject.youraccount.cloudbees.net
Click it and start playing around with your production online service!
One last small thing left to do: setup our domain. We’ll cover this in the next post.