The notion of a principal bundle over a groupoid generalizes the notion of a principal bundle over a manifold and that of a group homomorphism. It also includes equivariant principal bundles and principal bundles over orbifold. In this talk, we will discuss the Chern-Weil construction of characteristic classes in this general context, which unifies various constructions.