Here are some ideas that you might find useful...
(a) Assume that the spring behaves as a long solenoid. The magnetic flux through the central region of the solenoid will therefore be in which .
(b) The flux leaving the geometrical end of the solenoid (and entering the other end) will be (because at the end of a long solenoid, half the solenoid is missing!)
(c) But so the flux, , that doesn't leave through the geometrical end must leave through the sides of the solenoid in the region near the end (and must enter through the sides at the other end). It is the radial component of this flux that exerts an axial motor effect (Laplace) force on the end turns of the solenoid, squashing it.
(d) The axial component of the motor effect force on a length dz of the end region of solenoid, containing νdz turns is
(e) But is the flux, , leaving the sides of the solenoid over the length dz of solenoid.
(f) So the (axial) force on length dz of solenoid is
(g) Integrating, the total force on each end region is
(h) The spring as a whole is therefore under this compressive force (negative tension), just as if I were pushing each end inward with my hands. We have already assumed that the spring is long compared with its diameter, so the end regions, where the field splays out and the compressive forces arise, are short compared with the total length of the spring. It is therefore a reasonable approximation to neglect the fact that the end regions themselves are not compressed as much as the rest of the spring.
(h) The last step should be pretty straightforward!
Did you like this example?