how to disable jenkins pipeline job

前端 未结 7 1434
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-06 21:46

I am using pipeline jobs with Jenkins 2.0, but I don\'t see option \'disable job\' as I was used to in older Jenkins versions. Am I missing something? Is it still possible to di

相关标签:
7条回答
  • 2021-02-06 22:30

    You can simply use the "Disable Project" option from Jenkins 2.89.4 onward in order to disable the pipeline Jobs.

    0 讨论(0)
  • 2021-02-06 22:35

    If, like me, your Jenkins jobs are automatically created by a DSL workflow, you won't be able to edit the configuration of the top-level Job, that contains all the actual branches, to disable the automatic builds from github hooks. I can't currently find a way to programmatically disable an entire pipeline in the jenkinsfile, outside of using the when triggered by clause on every stage as mentioned in this other SO answer. Besides, that would cause it to run and succeed, which might not be what we want.

    So the solution that felt least-hacky to me was:

    1. Change the name of the Jenkinsfiles on all branches in your repo to something other than Jenkinsfile, so that Jenkins' SCM polling doesn't pick it up. I chose Jenkinsfile.manual. This assumes that the job-auto-creator is set to look for "Jenkinsfile"; adjust as necessary.
    2. The auto-created job should delete itself the next time it scans the repo, whether that's from the github hook, a scheduled scan, or you pressing "scan now".
    3. Manually create a new Multibranch Pipeline job for your repo, setting the Build Configuration to look for Jenkinsfile.manual (or whatever you choose to call it).
    4. Configure whatever branch Behaviors you would normally use, but also add a Property Strategy of All branches get the same properties > Suppress automatic SCM triggering.

    This feels "right" to me, your mileage my vary.

    0 讨论(0)
  • 2021-02-06 22:37

    If you don't find the disable button. This should do the trick for most of the Jobs. Just append /disable to the end of Job URL. Then Jenkins will redirect you to a page where you can Post. Same applies for /enable too

    0 讨论(0)
  • 2021-02-06 22:41

    For multibranch pipeline projects,

    • Click on pipeline 'configuration'
    • Under the 'Branch Sources', below 'Property Strategy'
      • click on 'ADD PROPERTY'
      • select "Suppress automatic SCM triggering"

    Now, no github branch trigger will run a build job. (This will disable triggers for all branches)

    0 讨论(0)
  • 2021-02-06 22:45

    There is no option to disable jenkins-pipeline job.

    The following jira ticket is tracking the issue:

    https://issues.jenkins-ci.org/browse/JENKINS-27299

    0 讨论(0)
  • 2021-02-06 22:46
    • go to job configuration
    • under "Build Triggers" select the "Disable this project"
    • save

    0 讨论(0)
提交回复
热议问题