Use Jenkins to Automatically Deploy a Git Repository to Heroku

I spent some of the weekend trying to get my git repository (Gitblit) to work with Jenkins and Heroku on one of my Windows servers. My plan was to set up a job in Jenkins that would poll my git repository every 15 minutes for changes and push any changes out to my Heroku application (Dexstr, for anyone who’s interested). I thought the process would be pretty simple, but I ran into a bunch of issues and it ended up taking me more than a few hours to finish.

I’ll run through everything I did to set up Heroku and Jenkins. All of these steps should be done on the machine that’s running Jenkins and not your dev machine.

1. Set Up Heroku

The first thing you’ll want to do is download Heroku Toolbelt; it’s going to install a CLI tool for managing your Heroku projects and a git client for you.

Once that’s installed, you’ll want to log in to Heroku, generate a SSH public key, and upload it to Heroku. It’s pretty simple, just run the following command in Command Prompt/PowerShell (or Terminal if you’re on OS X):

heroku login

It will ask for your Heroku credentials (email address and password). When generating your public key, if you’re on a private computer, feel free to leave the password blank (read more about it on Heroku’s support page).

Note: You should also be prompted at some point to add Heroku as a trusted host (if you’re on a Windows box). You’ll want to do this, it will make the Jenkins side of things a lot easier.

2. Generate a SSH Public Key

If you’ve already logged into Heroku using Command Prompt and somehow skipped generating a key, you can generate a new one at any time by running ssh-keygen. If you’re lucky, you should be able to just run the following in Command Prompt, but if you’re like me, you’ll need to run the second line instead:

ssh-keygen

“c:\program files (x86)\git\bin\ssh-keygen.exe”

Again, just skip the passphrase in most cases.

3. Upload Your Keys to Heroku

Alright, so now that you’ve generate your public key, it’s time to upload them to Heroku. Using the CLI tool that Heroku provides in the toolbelt that you downloaded earlier, run the following in Command Prompt:

heroku keys:add

This command should grab the keys generate in your user’s .ssh folder and upload them to Heroku. If you did this right, you should receive an email from Heroku saying a new key was added.

4. Install the Jenkins Git Plugin

This is another pretty simple step. Download the Git plugin through Jenkins’ Plugin Manager.

5. Create a New Jenkins Job

For my particular project, I just created a free-style software project job in Jenkins.

The first thing you’ll want to do while creating the job is to add both git repositories (your private git repository and Heroku’s repository) to Jenkins. In Heroku’s case, you’ll want to click on “Advanced” and name the repository something (like “heroku”).

For credentials, add the SSH public key by using the third bullet (From the Jenkins master ~/.ssh); the username for the public key can be found in the email that Heroku sent you earlier. Note: Make sure that Jenkins is running as the local user or you might run into trouble. More information here.

In my particular case, I chose to have the job poll my git repository every 15 minutes to look for changes. You can do the same by adding a build trigger by checking “Poll SCM” and enter the following in for the schedule:

H/15 * * * *

The last thing you need to do in Jenkins is to add a post-build action to push changes out to Heroku. The git plugin should give you the option of adding a “Git Publisher” step.

  • Check the “Push Only If Build Succeeds” option
  • Add a Branch; branch to push should be “master” and target remote name should be “heroku” (or whatever you named it previously)

Save the project and you should be good to go.

Looking back on all of this, I’d probably consider moving Gitblit, Jenkins, and Redmine (the software I use to manage my projects) over to a Linux box just because of the little Windows quirks that pop up when working on things like this, but that might just be because I’m using a Windows box and that the idea of a Linux box sounds better after wasting a few hours with permission problems.

Further Reading/Sources

  1. Continuous Deployment to Heroku With Jenkins
  2. Continuous Delivery for Heroku With Jenkins
  3. Running Jenkins in Windows with regular user account to see executables in PATH
  4. Managing Your SSH Keys
  5. Jenkins, GIT plugin and Windows

Bedtime Reading #10

Welcome back. The five links that you’ll be reading today involve a principle from psychology called anchoring, scammers in the internet marketing world, the Affordable Care Act, CrossFit, and a life hack.

Dan Ariely: Are we in control of our own decisions?

I’m starting out with another TED talk by Dan Ariely. His talk is about something called anchoring. To summarize it as quickly as possibly, basically everything is relative. You don’t know what a good deal is until you have another price to weigh against. Something you should keep in mind the next time you are making a big purchase.

Scamworld: ‘Get rich quick’ schemes mutate into an online monster

 

scamworld

A rather long article on The Verge about how some online marketers (alright, I’ll go as far to as a lot or most marketers) do business. The main reason I am sharing this is because it made me think about my plans for the somewhat near future and it makes me rethink some of the advice that I’ve been taking in for the better part of three years. I think most of the people that I follow offer solid advice and come from legitimate businesses, but this article still threw out some giant red flags; most notably, the idea of building a syndicate).

Obamacare Is A Net Positive For Early Retirees And The Underemployed

obamacare

I hate that I linked to an article that refers to the The Affordable Act as “Obamacare,” but it offers some information that’s worth reading. Sam Dogen’s bias is coming through a bit on the “Look on the bright side” headline, but it’s comforting to see that other people have faith in “the market.”

CrossFit’s Dirty Little Secret

crossfit-secret

I jumped on Ventrillo on Sunday night to play League of Legends with a few of my friends and one of the first things I heard was, “Hey Docken, have you heard of rhabdo?” I was fairly shocked after doing some “research” (read as: Wikipedia) and a quick Google search, The most shocking part of the article that I linked to is that CrossFit not only acknowledges it, some of the members actually take pride in it.

Take Action and Boost Teamwork with the ‘Unless I Hear Differently’ Strategy

uihd-strategy

 

I loved this life hack when I heard about it on The Fizzle Show. The jist is that you are following up on a discussion, turn it into a statement. “I will do X unless I hear differently.” It makes the assumption that what you’re doing is correct and you aren’t stuck waiting for a response from everyone in the room. It reminds me of the more efficient way of asking “Is everyone ready?” You should really be asking, “Is anyone not ready?”

That’s my five links for today. I won’t have any posts for the rest of the week as I’ll be out of town for a friend’s wedding in Duluth, Minnesota. Have a good rest of the week and don’t miss me too much.

Bedtime Reading #9

A fairly quick post today. I saw a really cool video about projection mapping, some advice on working out, and a lot about user interface design.

Box Demo

Box from Bot & Dolly on Vimeo.

I don’t have much to say about this video. I just thought it looked really cool, so I decided to share it. I know that’s not very insightful, but it’s still worth it.

99.99% of Guest Bloggers Don’t Do This & It Kills Their Conversions

guest-bloggers

Unbounce offers so good advice for guest blogging. I like most of the ideas presented in the article with one minor caveat; I don’t like the personalized page idea unless you you use the HTTP headers to determine the referral. I’d rather see a “Guest Post” page somewhere within your blog’s structure and redirect all guest post links to that one specific page. It’s rather annoying to be subscribed to a blog and see “Welcome Blah Blah Blah Readers to My Blog” come across the RSS feed every week or so.

Optimizing UI icons for faster recognition

faster-recognition

 

Image recognition and links is something that I’ve preached for about as long as I’ve worked on web sites and I’m glad to see that a recent study supports my argument. As the article suggests, when it’s possible to include an image or icon with text, once the user associates the image with the link, accessibility improves. In almost all usability studies I’ve seen, users tend to click on images or text when navigating  an interface. Take advantage of it.

On Writing Interfaces Well

writing-interfaces

 

The Signal vs. Noise blog by 37signals always offers great advice and this is just another solid post about how important words are. I’ve read studies regarding conversion rates on long copy pages and they tend to have a higher conversion rate than pages that have their opt in above the fold (and only above the fold). Remember that you need to build trust before you can convert.

 

6 Truths About Exercise That Nobody Wants to Believe

exercise-truths

 

I saved James Clear’s advice on exercise for last. I’m actually using the ideas from this post as inspiration for a website (and mobile phone app) that I hope to will release by the end of the year (if you don’t hear about it by the end of 2013, please yell at me by any means possible).

That’s it. Let me know in the comments below what you thought about what you saw today.

Bedtime Reading #8

The Internet at my house died while I was writing this, so it’s coming out a bit later than normal today. I’ll eventually write this in advance and schedule when they will be published, but until then, I’ll occasionally run into problems like this.

Expect to hear and read a few psychology studies ranging from pain tolerance to helplessness. You’ll learn how to not suck at blogging and if blowing on a Nintendo cartridge really made a difference and most importantly, how to raise a child (presented to you in an extremely sarcastic way).

Dan Ariely: Our buggy moral code

Ariely’s stories are a little gruesome (especially his pain study), but he offers some interesting knowledge regarding pain. Do the painful things first, less painful things last. Longer time periods (with breaks) with a lower intensity is better for pain management as well. Also, his cheating study is fantastic.

Learned Helplessness

learned-helplessness

Continuing along with psychology, I was reminded earlier today about some research done by Ivan Pavlov in the late 1800′s. The article that I’m sharing takes his study a bit further and studies how people and animals handle situations that they have little control over. The idea helps explain why people end up staying in bad situations and my hope is that by knowing why your brain does this that you can get out of it.

Did Blowing into Nintendo Cartridges Really Help?

nintendo-cartridge

I probably should have listened to my parents when they said don’t blow on the cartridge. SPOILER: It ruins the cartridge. Don’t believe me? Look at the picture at the end of the article (and that’s only after a month of…. excessive… blowing…).

How NOT To Suck At Blogging

not-suck-blogging

I was reminded of this post by the guys from The Fizzle Show. J.D. Roth offers some great advice for beginning bloggers (like me). The basic advice is the following:

  1. Be passionate
  2. Don’t expect to get paid
  3. Be flexible with the blog’s purpose
  4. Become an expert
  5. Be transparent
  6. Focus on content (don’t worry about design)
  7. Build relationships
  8. Find mentors
  9. Team up with another blogger

…and a bunch more. It’s worth reading the entire post and watch the videos because they are coming from some big name players (Gary Vaynerchuk and Tim Ferriss).

Illustrated baby handling guide for dumb parents

dumb-parents

I’ll end this one with a little bit of humor that I’ve been sharing with one of my best friends that had his first child last fall. I probably sounded like a crazy person as I saw each picture.

That’s a wrap. As always, let me know what you thought in the comments below. I’d also love it if you shared something that you read today that was interesting.

Bedtime Reading #7

Opening

Between newsletters, social media feeds, and my RSS feeds, I almost feel like I’m cheating when I find stuff to share (the videos are a little bit of a struggle, but I’ve watched enough TED talks to keep the content flowing). I’m going to mention a lot about entertainment below (mostly sports… football), but I also found a bit on business and some fashion advice.

The Future of the American Dream: Sean Ogle at TEDxCMU 2012

I’ve linked to Sean’s blog, Location 180, a couple times so far, so I figure I should share his TED talk. I have a hard time not going thinking about this talk when I have rough stretches at work, especially when I think about how vacation time works in the corporate world.

How Should a Suit Fit? Your Easy-to-Follow Visual Guide

suit-fitIf you would have asked me a year or two ago that I would care about what I wore, I would have laughed in your face. This changed a few months back and I now pay attention at least a little bit to what I wear. It makes a huge difference. Every guy in the United States should read and understand how to wear a suit.

Magician David Copperfield’s $800 Million Fortune Could Make Him A Future Billionaire

copperfield-fortune

 

I knew David Copperfield was a successful musician, but I didn’t realize how smart he was with his success. Forbes ran this profile of Copperfield today that talked about how has managed his assets. Not only does he have his own daily show in Vegas, he also owns a couple properties, owns a private museum. and a group of islands. Pretty impressive, right?

19 Sports Injuries Weirder Than Nate Burleson’s

sports-injuries

 

Nate Burleson crashed his car less than week after Aldon Smith was arrested on suspicion of DUI. Now Burleson wasn’t drinking, but he managed to break his arm (something Smith managed to avoid), which apparently isn’t the worst thing that can happen to you if you’re an athlete and get hurt off the field. I mean, breaking a rib from food poisoning or getting bit by a coyote take the cake, right?

NFL Star Arian Foster: 6 Things I’ll Try to Teach My Daughter

arian-foster-daughter

 

I started following Arian Foster a few years back when he tried a vegan diet (he’s subsequently quit the plan, if you couldn’t figure it out from the link). So I was pretty intrigued when I saw that he wrote this article. From happiness and self worth to religion, he nails pretty much all of it on the head. Just a few more words of advice that I need to tuck away for the future.

That’s it for today. It’s pretty interesting to see my progress in writing these posts over the last week or so. I think the first post took me nearly an hours between screen shots (and Photoshop), finding the content, and writing a quick opinion about it. Considering it took me about twenty minutes today, I’m pretty happy about it.

As always, let me know what you thought about what you read today.

Bedtime Reading #6

Today I’m sharing a horribly long video about sugar today, along with two lists of life lessons, a motivation post, and one post about how perfection isn’t worth achieving. Here we go…

Sugar: The Bitter Truth

Sorry about the 90 minute video… The two biggest things to take away from Dr. Robert Lustig is that scientific studies (well, technically anything) can be spun in a certain way by using math/science in a misleading way and the early evidence of heart disease in American soldiers during the Vietnam War that he blames on sugar consumption. He later goes on to make a statement along the lines of “the antidote is always with the poison,” which he refers to fiber as the antidote to sugar and he uses fruit as an example. Just something to consider when chosing the food that you eat.

Better is the enemy of best

better-best

37signals had a really good post earlier this month that talked about when things are “good enough.” The basic premise is that if you are spending all of your time finding the best things to use, you won’t actually accomplish anything. Chase uses a story about Tommy Attridge to prove his point that you need to eventually stop trying to perfect a project (hint: it’s not possible) and just get it out there.

18 Life Lessons Learned From Travel The World

travel-lessons

A fairly standard list post about travel, but it’s still good to read these kinds of posts from time to time. The underlying point that I took away from this post? Don’t be a sheep. Try new things, be adventerous, make mistakes, it’s never too late, learn more, and probably most important… Relax.

The Only Post You’ll Need to Do Something Extraordinary

something-extraordinarySean Ogle ran this link bait article today that’s loosely based on bucket lists. His post provides links to a lot of the “lifestyle design entrepreneurs” that I follow, so at the very least, it’s a good resource to find other good blogs to read.

20 Things 20-Year-Olds Don’t Get

20-thingsForbes ran this article in July of this year. Some fairly solid advice from an entrepreneur. The two major stand outs for me is pick up the phone and spend 25% less than what you make.

I was a bit distracted today with ESPN E:60 and talking with my roommate, so the descriptions today took a bit of a hit. I’ll try a bit harder tomorrow.

Bedtime Reading #5

There’s a fairly wide range of topics today, so hopefully I have covered something for everyone that’s reading my blog. I’m starting out with another one of my favorite videos on TED about creativity. The second link serves as a warning that everything on the Internet won’t be around forever (and I’m willing to bet that a fair amount of the links that I share will be dead within a year). The third and fourth links are here for my entrepreneur friends that talk about starting a blog and using Facebook. And the last link covers ESPN’s soccer power index in detail (something stats nerds and sports nerds should love).

Ken Robinson: How schools kill creativity

If it weren’t for Mike Rowe’s talk, this TED talk by Sir Ken Robinson would be my favorite one. Not only is the information worth hearing, the presentation style is highly entertaining. He explains how important it is to remain creative throughout your life.

Good Content Is Too Valuable To Die

good-content

This post on Smashing Magazine is something that I experienced when I burned through 54,000 bookmarks a few months back. People always say that everything you put on the Internet stays around forever and while that is for the most part true, it doesn’t say anything about how difficult it is to find something after it’s gone.

How I Launched a Blog (From Scratch)

launched-blog

I’m being a bit selfish by sharing this post. I plan on starting a couple different blogs in the next few weeks (One probably focusing on fitness and the other focusing on video games. I know… it’s ironic). I’m going to follow this guide by Tom Ewer for one and then Marcus Sheridan’s 12 step guide for the other. You should be seeing updates here as to how that’s going, so if you don’t, make sure you start yelling at me.

How to Become a Facebook Expert in 48 Hours

facebook-expert

If you ever need an example of a corner stone post for a website, this guest post is a perfect example of it. The post is really long (seriously, it’s long) and will probably take a couple of days to get through if you actually take action (something I plan on doing twice based on the two blog plan),but it’s pretty much everything that you should need to get started with commercial Facebook profiles.

A guide to ESPN’s SPI ratings

spi-ratings

Nate Silver’s writing on the soccer power index is the biggest reason why I am interesting in mathematics and statistics. It’s also the reason why I want to start a website that focuses on sports betting and fantasy sports (because let’s be honest here, they are both built on the same principles).

Again, thanks for reading. I hope you found at least one of the links interesting. Let me know in the comments below what you liked (or didn’t like!) so I can gradually improve the stuff that I’m sharing based on your interests.

Bedtime Reading #4

Again, just sticking with a video and four links. You’ll hear from/about (1) Mike Rowe of Dirty Jobs, (2) Ryan Carson of Treehouse, (3) a guy who promotes the paleo diet, (4) the greatest soccer coach, and (5) how people are terrible at choosing leaders.

Mike Rowe: Learning from Dirty Jobs

This is probably my all time favorite TED talk. I never remember hearing anything good about blue collar work growing up and frankly, there wasn’t an option about not going to college in my high school (if you were roughly in the top half of the class, the question wasn’t if you were going to college, it was where were you going to college),

Funny how some of the best paid workers right now are welders working in western North Dakota right now. I mean, who could have predicted that 10 years ago?

No Managers: Why We Removed Bosses at Treehouse

no-managers

If you’ve ever had a conversation with me about work, you know that I have some very strong opinions about the way that people (especially Americans) work these days. I heard about a really interesting way of handling work from Ryan Carson, the CEO of Treehouse. I really want to see how this pans out for him since I’m a huge fan of the idea.

What Is The Origin Of Cancer?

origin-of-cancer

I feel a little brainwashed by sharing this article since I loosely follow the paleo diet (I try to avoid most grains and sugars as best as I can). It’s a really long post that shares some interesting, although dated, studies on cancer research. I figure it’s keeping in the back of your mind for when the inevitable cancer discussion comes up.

The basic idea, since it’s really long is that the article claims that cancer gets its energy from glucose and that by lowering the amount of carbohydrates that one consumes, the cancer is essentially “starved.” I’m not trying to make it sound like cancer is a simple problem (it’s not), but a different is perspective is nice considering no one is really beating cancer.

Ferguson’s Formula

ferguson-formula

 

Sir Alex Ferguson might not be the best coach ever (I mean that goes to Mike Krzyzewski, right?), but he’s probably the best football (soccer) coach that I’ll ever see. His ideas don’t just apply to sports, they apply to life.

A fatal flaw when choosing the right leader

right-leader

 

I’m trying my hardest to keep myself humble and one of my friends sends me this article on the BBC. It stresses that people should be choosing leaders based on how well they adapt to new situations, not based off of their experience, knowledge, or what they’ve accomplished.

Thanks for reading and that’s it for this week. I’m heading to the gym and taking the weekend off.

Bedtime Reading #3

I strongly considered not sharing a couple of the following links, but finally decided that it was a good call for a couple decisions:

  1. The points made in the article are legitimate. Although I may agree with the entire idea, crucial parts of the post hit home.
  2. It should provoke, hopefully healthy, discussions (especially the Forbes article).

Why Are American Health Care Costs So High?

Even if you don’t agree with anything he says about health care, the video itself is impressive (and entertaining!). Maybe I just align with this guy 100%, but I felt like the points were fairly unbiased — one of the comments suggested that he went off the deep end around 5:15, but his point seemed valid.

‘Survivors, scrapers:’ Why the middle class feels like it just can’t get ahead

middle-class

 

Okay, I’m going to pick on this article a bit. The first statistical point of the article is that the real median income went up about $100 after inflation since the previous year; not only is this a small sample size, it also adjusts for inflation (but I guess you wouldn’t have much of an article if you said income went up $1500, or 3%). It also closed with a comment about there is never money left over and there’s a simple way to explain that — people spend what they make. I remember some guy in Chicago a few years back struggling when he made $250,000 $400,000 a year.

France moves to ban child beauty pageantchild-pageants

This. Is. Awesome. I don’t understand how you could argue against a law like this. You probably don’t need to show off your (non-existent) body if you’re under 16.

Give Back? Yes, It’s Time For The 99% To Give Back To The 1%

give-back

 

This is where things get interesting. The points that I agree with in the article is that it seems like society tends to villainize successful people (for the sake of this argument, I will say that success is defined by making a lot of money). The tax break comment is a bit extreme (and unrealistic), but it’s nice to see someone suggest incentive for making sacrifices to be successful.

Surviving Whole Foods

whole-foodsForewarning: This is satire. I’m fairly selective about my food these days. For the most part, I’ve cut out deep fried food and a lot of breads and pastas. I try to avoid sugar as much as I can, but I still drink pop/soda. If anything, it’s a good reminder that you should take something that’s widely considered good to an extreme (This holds true to religion, politics, anything and everything). And the part that I appreciated most from the article? This.

I’m not rich enough to have dietary restrictions. Ever notice that you don’t meet poor people with special diet needs? A gluten intolerant house cleaner? A cab driver with Candida? Candida is what I call a rich, white person problem. You know you’ve really made it in this world when you get Candida.

And that’s a wrap. Again, I’m sorry that I gave into an influx of posts that are a bit overly political for me, but I want to see how it goes. Let me know your opinions on what you read in the comments below.

Bedtime Reading #2

It’s time for round two of the semi-new daily post idea. I was a bit worried at the beginning of the day when I burned through 60 headlines in Feedly and didn’t find anything worth mentioning, but as the day went on, I found plenty (and I’m already starting to get ahead in posts).

I’m also starting to form a pattern on what I want to share with these posts. I will challenge myself to share one or two videos a day, along with one or two older posts in an effort to not get stale content if people somehow manage to follow the same sites that I follow. I also want to put a bit more emphasis on personal blogs or businesses instead of mainstream news sources, although you can still expect to see some syndicated news and opinion pieces from places like Forbes or The Huffington Post.

Amy Cuddy: Your body language shapes who you are

I wanted share Amy Cuddy’s TED talk on power poses because of something I saw the other day. 30 Great Interactive Sites over on Web Designer Wall showcased the website for Bienville Capital Management. When I clicked on their “Team” page,the following picture reminded me of Cuddy’s speech.

If that's not a power pose, I don't know what is.

If that’s not a power pose, I don’t know what is.

How Formal Education Killed the Passionate Career (+ A Practical Guide for Students, Parents & Lifelong Learners)

formal-education

 

If you’ve ever heard me talk about my college experience, you know that I agree 100% with Scott Dinsmore on formal education. If you can challenge any of the points in his post, I’d love to hear it. His third and fifth point solidify one of my ideas for when I start my own successful business (more on that in a future post). Also, there’s a list of about 10 other posts from Live Your Legend at the bottom of the article, all of those are worth a read as well.

Why I Never Joined Facebook

facebook

 

Let’s be honest here, we’re all probably wasting too much time on Facebook. The big take away from this is to always ask yourself, “How does this solve a problem that I have?” If you can’t answer the question, you probably shouldn’t be doing it.

 How to Get National Press With No Budget (Plus: One Year of Mentorship from Alexis Ohanian)

national-press

 

Some more great content from Alexis Ohanian on Tim Ferriss’ blog. Since I shared the one yesterday, I felt obligated to share the second post. He’s also selling a book that you might want to check out: Without Their Permission: How the 21st Century Will Be Made, Not Manage (Not an affiliate link because Minnesota is awesome like that. /sarcasm, but for real, it’s not an affiliate link).

The 100 Things Every 20-Something Needs To Realize

100-things

 

I’m closing with something one of my friends shared on Facebook this afternoon. If you aren’t willing to read all of them, you’re really lazy. Each point is a sentence. But seriously, if you can’t make it through all of them, at the very least, skip to the bottom and read the last 15. Take those to heart. Especially…

If you don’t work to improve yourself everyday then you are wasting your life.

That’s a wrap for today. Since I already have an idea of what I’ll be sharing tomorrow, I apologize in advance for the political theme (even though I hate politics).