In this study, we used bioinformatics tools to analyze transcriptome data from cholangiocarcinoma (CCA) patients in multiple datasets (Sun Yat-sen University, TCGA and GSE32225 cohorts) to identify mechanisms that regulate tumor infiltration by immune cells and survival outcomes. We identified 96 differentially expressed genes (DEGs), including 13 upregulated and 83 downregulated genes, in CCA tissues as regulatory T cells were significantly higher and the proportions of activated natural killer cells and monocytes were significantly lower in CCA tissues than the precancerous tissues. The survival outcomes of CCA patients were associated with the TP53 gene mutation status, levels of Oncostatin M (OSM) expression, and the proportions of tumor-infiltrating immune cell types, including dendritic cells, monocytes, and T follicular helper cells. Functional enrichment analysis of the DEGs in the high OSM-expressing CCA tissues showed that pathways related to tumor progression and immune response were significantly upregulated. Our study demonstrates that OSM expression and TP53 mutation status regulate the tumor infiltration by immune cells and survival outcomes in CCA. OSM is thus a potential prognostic biomarker and therapeutic target in cholangiocarcinoma.