I don't see anything against doing so, but experience has suggested a few complications you'll need to address.
Pipes take up space. This can mean there's no room for a box, anchoring the cables can be difficult, and that the cables will need additional protection when the piping pushes them too close to the wall.