In the design and troubleshooting of aero-engine pipeline, the vibration reduction of the pipeline system is often achieved by adjusting the hoop layout, provided that the shape of pipeline remains unchanged. However, in reality, the pipeline system with the best antivibration performance may be obtained only by adjusting the pipeline shape. In this paper, a typical spatial pipeline is taken as the research object, the length of straight-line segment is taken as the design variable, and an innovative optimization method of avoiding vibration of aero-engine pipeline is proposed. The relationship between straight-line segment length and parameters that determine the geometric characteristics of the pipeline, such as the position of key reference points, bending angle, and hoop position, are derived in detail. Based on this, the parametric finite element model of the pipeline system is established. Taking the maximum first-order natural frequency of pipeline as the optimization objective and introducing process constraints and vibration avoidance constraints, the optimization model of the pipeline system is established. The genetic algorithm and the golden section algorithm are selected to solve the optimization model, and the relevant solution procedure is described in detail. Finally, two kinds of pipelines with different total lengths are selected to carry out a case study. Based on the analysis of the influence of straight-line segment length on the vibration characteristics of the pipeline system, the optimization methods developed in this paper are demonstrated. Results show that the developed optimization method can obtain the optimal single value or interval of the straight-line segment length while avoiding the excitation frequency. In addition, the optimization efficiency of the golden section algorithm is remarkably higher than that of the genetic algorithm for length optimization of a single straight-line segment.