Depending on the operational environment, installation location, and aging of oil and gas pipelines, they are subject to various degradation mechanisms, such as cracking, corrosion, leaking, and thinning of the pipeline walls. Failure of oil and gas pipelines due to these degradation mechanisms can lead to catastrophic events, which, in the worst case, may result in the loss of human lives and huge financial losses. Traditionally, paper-and-pencil proof methods and Monte Carlo based computer simulations are used in the reliability analysis of oil and gas pipelines to identify potential threats and thus avoid unwanted failures. However, paper-and-pencil proof methods are prone to human error, especially when dealing with large systems, while simulation techniques primarily involve sampling-based methods, i.e., not all possible scenarios of the given systems are tested, which compromises the accuracy of the results. As an accurate alternative, we propose to use a higher-order-logic theorem proving for the reliability analysis of oil and gas pipelines. In particular, this paper presents the higher-order-logic formalization of commonly used reliability block diagrams (RBDs), such as series, parallel, series-parallel, and k-out-of-n, and provides an approach to utilize these formalized RBDs to assess the reliability of oil and gas pipelines. For illustration, we present a formal reliability analysis of a pipeline transportation subsystem used between the oil terminals at the Port of Gdynia, Poland, and Dębogó rze.