An important trick here is that sigma and integral signs can be changed around.
$\int \sum^b_{n=a} f\left(n,x\right)\, dx = \sum^b_{n=a} \int f\left(n,x\right) \,dx$
And this is because
$\int \sum^b_{n=a} f(n,x)\, dx$
$\int f\left(a,x\right) + f((a+1),x) + f((a+2),x) + \dots +f\left((b-1),x\right) + f(b,x) $
$ = \int f(a,x)\,dx + \int f((a+1),x) \,dx + \dots + \int f((b-1),x)\, dx + \int f(b,x)\, dx$
Therefore
$\begin{align*} \sum_{n=0}^m \frac{1}{(3n+1)(3n+2)} =& \sum_{n=0}^m \left( \frac{1}{3n+1} - \frac{1}{3n+2} \right) \\ =& \sum_{n=0}^m \int_0^1 \left( x^{3n} - x^{3n+1} \right) \mathrm{d} x \\ =& \int_0^1 \sum_{n=0}^m \left( x^{3n} - x^{3n+1} \right) \mathrm{d} x \\ =& \int_0^1 \left( \frac{(1-x^{3m+3}) (1-x)}{1-x^3} \right) \mathrm{d} x = \int_0^1 \frac{1-x^{3m+3}}{1+x + x^2} \mathrm{d} x \end{align*} $
Also because $ \sum_{n=0}^m \left( x^{3n} - x^{3n+1} \right) = \frac{(1-x^{3(m+1)})(1-x)}{1-x^3} $
Now let us see how the final integral
$\sum_{n=0}^\infty \frac{1}{(3n+1)(3n+2)} = \int_0^1 \frac{\mathrm{d} x}{1+x+x^2} $
is evaluated.
$ x^2+x+1 = \left(x+\frac{1}{2}\right)^2+ \left(\frac{\sqrt{3}}{2}\right)^2$
therefore if you skip two steps of substitution and do it once
$ x+\frac{1}{2} = \frac{\sqrt{3}}{2} tan \theta$
$ dx = \frac{\sqrt{3}}{2} sec^{2} \theta$
$ \begin{eqnarray} \int \frac{dx}{1+x+x^2} = \int \frac{ \frac{\sqrt{3}}{2} sec^{2} \theta}{\frac{3}{4} sec^{2} \theta} {\mathrm{d} \theta} &=& \frac{2}{\sqrt{3}} \theta \\ &=& \frac{2}{\sqrt{3}} tan^{-1} \left(\frac{2x+1}{\sqrt{3}}\right) \end{eqnarray} $
$ \Rightarrow \int_0^1 \frac{\mathrm{d} x}{1+x+x^2} = \frac{2\sqrt{3}}{3} \left( tan^{-1} ( \frac{3}{\sqrt{3}} ) - tan^{-1} ( \frac{1}{\sqrt{3}} ) \right)$
$ = \frac{2\sqrt{3}}{3} \left( \frac{\pi}{3} - \frac{\pi}{6} \right) = \frac{\pi}{3\sqrt{3}}$