No.
Take $X=Spec(k[x^2,x^3])$, the cusp over the field $k$ , the trivial bundle $Y=X\times_k\mathbb A^1_k $ and the first projection $f=pr_X:Y\to X$ .
Every line bundle$M$ on $Y$ is trivial on the fibers, since said fibers are affine lines over the field $k$. However not every line bundle $M$ on $Y$ can be written $f^*L$ with $L$ a line bundle on $X$.
Here is why:
A ring $R$ is called semi-normal if whenever elements $a,b \in R$ satisfy $a^3=b^2$, you can conclude that there exists $r\in R$ with $a=r^2, b=r^3$ . The ring is then automatically reduced (strange, eh?Costa). This notion is due to Traverso and Swan.
(For[Strange condition, eh? For example, a normal domain $R$ is semi-normal: take $r=b/a\in Frac(R)$, which by normality must be in $R$ since it satisfies the integral monicintegrality equation $r^2-a=0$. )
A]
A theorem of Swan then states that given a ring $R$, the map from $R$ to its polynomial ring $j:R\to R[T]$ induces a surjection $j^*:Pic(R)\to Pic(R[T])$ if and only if the reduced ring $R_{red}=R/Nil(R)$ is semi-normal.This This proves the above claim about the cusp (and much more).
Bibliography:
a) Here is a nice, completely self-contained survey by Lombardi and Quitté on semi-normal rings. Its bibliography will lead you to the original articles by Traverso and Swan.
b) And there is another very nice survey by Vitulli.