Various risk factors of urban gas pipelines will lead to leakage, significantly impacting the environment, assets, and life safety, thus making pipeline risk prevention and control crucial. However, existing methods cannot sufficiently model the uncertainty in the pipeline risk evaluation process. In addition, the calculation method of factor weights may lead to unrealistic results. In this study, variable weight theory and cloud theory are introduced. Then, a novel method of cloud-variable weight function is proposed to analyze the pipeline's risk level and critical risk factors by establishing a pipeline risk assessment index system. The proposed method fully considers the uncertainty in the evaluation process, resolves the contradiction of existing methods to model the fuzzy concepts accurately, optimizes the weight distribution, and obtains a more scientific and reasonable assessment result. A case study is conducted on a pipeline in Beijing City. The results illustrate that the proposed method is beneficial for helping pipeline operators determine the pipeline risk status and weak links in the pipeline system, thereby providing a basis for risk control and rehabilitation.