Though I often don't take my own advice, I try to ask is what I'm about to build core to our ROI/product, is there an existing solution that gets us 80% there, and yes, what is the cost.
If it is not core to the business, won't drive revenue, and cost are not outrageous, which is a company by company truth, then I much prefer to spend X time building new product than recreating an existing product/tool.
One final point - don't forget to consider the maintenance costs, which in the long term often greater then the initial investment. If your CI goes down, you just blew away and savings you were planning on.