The role of socialism and communism in World War I was limited in that neither of these political systems had actually been implemented in governments of the period and they existed only as movements and ideologies advocated by limited numbers of people. However, there is another way in which we could argue that communism and associated ideologies served as bookends to the war, both involved in the events that precipitated it and helping it draw to a close.
The event that started World War I was the assassination of Archduke Franz Ferdinand of Austria on 28 June 1914, although it can be argued that this exacerbated existing tensions rather than bearing sole responsibility for the war. The assassin was part of Mlada Bosna (Young Bosnia) a revolutionary movement that was a mixture including nationalists and socialists and thus one can argue that the socialists in the group were part of the event that started the war.
The Russian Revolution was in part caused by broad dissatisfaction with World War I. After the Russian Revolution of 1917, Lenin, leader of the new socialist government, negotiated a treaty with Germany and the Central Powers. During 1918, Russia's attention turned inward, and its involvement in the war was limited.