jenkinsjenkins-pipelinemultibranch-pipeline

Is there a way to remove Jobs/Pipelines from a Jenkins Multibranch pipeline item without deleting the branch in the SCM?


First off, I'd like to clarify this is not relating to setting the Orphaned Item Strategy which deals with Jobs for removed SCM heads. Orphaned Item Strategy will prune the job is the Branch which created the pipeline is also deleted, but as stated in the title without deleting the branch in the SCM is the goal here.

Also I am familiar with the buildDiscarder

options {
        buildDiscarder logRotator(artifactDaysToKeepStr: '1', artifactNumToKeepStr: '3', daysToKeepStr: '1', numToKeepStr: '3')
    }

Which removes the jobs/artifacts based on the number of builds or time passed.

However, for this example looking at this Multibranch Pipeline, I already manually removed all the builds from 'feature/Jenkins_Update' Jenkins Multibranch view showing 4 separate branches and their build status info

But when I access the drop down for 'feature/Jenkins_Update'

Shows dropdown options when selecting the branch 'feature/Jenkins_Update' from the previously pictured Multipipeline View

There is no delete option. This delete option appears if the branch associated with this Job/Pipeline is deleted, but I'm trying to figure out if there is a way to leave branches for git history purposes, but remove them from cluttering up the Jenkins interface.


Solution

  • So fakolours proposed removing the Jenkinsfile in said branches.

    Originally, I was worried this would only be a temporary fix, but if this is for stale branches then that negates the original concern. I was also hopeful the admin of Jenkins would be able to see alternative options when they attempted the same steps I had in the question above, but they confirmed they did not.

    The plan now is to implement a webhook on successful merge which will call a script. That script will checkout the branch that was just successfully merged, rm Jenkinsfile, then commit. This will achieve the original goals of maintaining that specific branch commit history, while also allowing for the deletion of the related Job/Pipeline in Jenkins.