Facing the growing pressure of climate change and environmental protection, integrated energy systems (IESs), which comprise different energy sources, have become promising candidates for future energy systems. However, the capacity configuration of each source remains challenging due to the various couplings, randomness of renewables and numerical optimization difficulty. In this paper, a hierarchical optimization framework is proposed to determine the component capacities of trigeneration IESs, i.e., systems involving combined cooling, heating and power (CCHP) generation. The potential variation in the demand and renewable resource availability are considered stochastic factors and captured as scenarios generated according to a probability function. In the first level, with the component capacities and scenarios defined, a mixed-integer linear programming (MILP) problem is formulated to minimize the total system cost. Then, in the second level, the Monte Carlo method is applied to calculate the expectation by feeding different scenarios into the MILP and sampling the minimal costs. Finally, as the second level returns the expected value of the system cost considering the given component capacities, a genetic algorithm is adopted in the third level to search the optimal component capacities. Compared to the conventional deterministic optimization method, the proposed stochastic optimization method reduces the annual operational cost while allowing a wider operational range. In addition, it is revealed that the inclusion of heat storage and grid connections yields notable benefits in terms of IES cost reduction.