2 added more details
source | link

The most flexible solution is a Pattern Brush. This is what joojaa meant with "the gradient does not need to be that path" - the gradient is simply a pattern applied to the path.

  1. because Illustrator doesn't accept gradients in brushes, you need to create a blend object. Draw 3 rectangles and fill them with the colors of your pipe + shadow profile.
  2. Blend Tool (W) and click on each rectangle in sequence, like this: enter image description here
  3. Drag the blend object to the Brushes panel (F5 if it's not open) and select Pattern Brush
  4. Adjust the settings for the corners enter image description here
  5. draw a "spine" for your pipe - a single open path with no fill
  6. Select the brush on the Brushes panel to apply to your pipe: enter image description here

Advantages:

  • you can easily change the colors of the gradient later
  • you can easily change the shape of the pipe afterwards
  • you can apply the same pattern to other objects

The most flexible solution is a Pattern Brush.

  1. because Illustrator doesn't accept gradients in brushes, you need to create a blend object. Draw 3 rectangles and fill them with the colors of your pipe + shadow profile.
  2. Blend Tool (W) and click on each rectangle in sequence, like this: enter image description here
  3. Drag the blend object to the Brushes panel (F5 if it's not open) and select Pattern Brush
  4. Adjust the settings for the corners enter image description here
  5. draw a "spine" for your pipe - a single open path with no fill
  6. Select the brush on the Brushes panel to apply to your pipe: enter image description here

Advantages:

  • you can easily change the colors of the gradient later
  • you can easily change the shape of the pipe afterwards
  • you can apply the same pattern to other objects

The most flexible solution is a Pattern Brush. This is what joojaa meant with "the gradient does not need to be that path" - the gradient is simply a pattern applied to the path.

  1. because Illustrator doesn't accept gradients in brushes, you need to create a blend object. Draw 3 rectangles and fill them with the colors of your pipe + shadow profile.
  2. Blend Tool (W) and click on each rectangle in sequence, like this: enter image description here
  3. Drag the blend object to the Brushes panel (F5 if it's not open) and select Pattern Brush
  4. Adjust the settings for the corners enter image description here
  5. draw a "spine" for your pipe - a single open path with no fill
  6. Select the brush on the Brushes panel to apply to your pipe: enter image description here

Advantages:

  • you can easily change the colors of the gradient later
  • you can easily change the shape of the pipe afterwards
  • you can apply the same pattern to other objects
1
source | link

The most flexible solution is a Pattern Brush.

  1. because Illustrator doesn't accept gradients in brushes, you need to create a blend object. Draw 3 rectangles and fill them with the colors of your pipe + shadow profile.
  2. Blend Tool (W) and click on each rectangle in sequence, like this: enter image description here
  3. Drag the blend object to the Brushes panel (F5 if it's not open) and select Pattern Brush
  4. Adjust the settings for the corners enter image description here
  5. draw a "spine" for your pipe - a single open path with no fill
  6. Select the brush on the Brushes panel to apply to your pipe: enter image description here

Advantages:

  • you can easily change the colors of the gradient later
  • you can easily change the shape of the pipe afterwards
  • you can apply the same pattern to other objects