This is Gimp 2.10 only, a very old RobA script,
Draw your gradient into a canvas. Make a path to sample colours. The script is right-click in the gradients dock near the bottom. It is old so if you use it more than once in the same session it can pop-under the Gimp window (just saying).
Run it. Fill in the number of samples value and name of the new gradient. Ok it, then refresh the gradients for it to show in the gradients dock.
Draw your gradient into a canvas. Make a path to sample colours. The script is right-click in the gradients dock near the bottom. It is old so if you use it more than once in the same session it can pop-under the Gimp window (just saying).
Run it. Fill in the number of samples value and name of the new gradient. Ok it, then refresh the gradients for it to show in the gradients dock.