First, create a Gradient:
You can get hard edges in a gradient by placing color stops at the same location. For example, above there is a red and an orange color stop both at 15%, then an orange and a yellow color stop both at 30%, then repeated for yellow/green, green/blue, blue/purple.
Then, draw one shape. Duplicate and move it. Use the Shape Builder Tool to drag across areas that need to appear on top... and lastly apply the gradient you just made.
(Final colors here are a bit muddy due to gif dithering.)
If you must use a Clipping Mask, the overall construction is the same.. duplicate shape and use the Shape Builder Tool.
Then..
- Copy both shapes.
- Move your image to be clipped into place and behind the shapes
- Select the image and first shape and choose
Object > Clipping Mask > Make
- Repeat for the second shape
Now if you want a stroke on all of it, adding strokes to clipping masks can be problematic. it is often best to replicate the mask path to add the stroke. To do this.... since I copied the shapes already and they are on the clipboard.
- Choose
Edit > Paste in Front
. This will paste the shapes I copied exactly in the same position where they were copied, but on the top of the object stack.
From here, it's just a matter of removing the fill and adjusting the stroke.
So this builds 2 clipping mask shapes, then 2 additional shapes on top for the strokes.
When it's all aligned things look as they should...
Just select all and Object > Group
to keep it all together.