<p>I wonder the purpose of adding clean up stage in Jenkins CI/CD pipeline to remove release if exist with <code>helm delete</code> command. What is the main purpose ans use case that we need to clean up the environment that we would like to deploy?  Is that still necessary for using <code>upgrade install</code> command for helm.</p>

<pre><code>helm upgrade --install a-service
</code></pre>

semural
<p>When you do <code>helm delete $RELEASE_NAME</code> it deletes all resources but keeps the record with $RELEASE_NAME in case you want to rollback. You can see removed releases via <code>helm ls -a</code> . Whereas <code>helm delete --purge $RELEASE_NAME</code> removes records and make that name free to be reused for another installation.</p>

<p>If your initial release ends up in a failed state then running <code>helm upgrade --install a-service</code> will throw error </p>

<pre><code>$ helm upgrade "foo" . --install 
Error: UPGRADE FAILED: "foo" has no deployed releases
</code></pre>

<p>Then you need clean it up using </p>

<pre><code>helm delete foo --purge
</code></pre>
