How to batch disable/enable Jenkins jobs in Bash

Source: Internet
Author: User
Tags curl

There are a large number of old jobs on Jenkins that don't need to be run. We want to disable these jobs in batches. Later, we found that Jenkins provided a very simple way to operate through curl.
A simple Bash script for disable jenkins job is written as follows:

The code is as follows: Copy code
#! /Bin/bash
Jobs = "my-test-job-1 my-test-job-2 my-test-job-3"
 
User = "user"
Password = "password"
Curl = "curl -- user $ user: $ password"
Jenkins_url = "http://myjenkins.com"
For j in $ jobs
Do
Disable_url = "$ curl-o/dev/null -- data disable $ jenkins_url/job/$ j/disable"
# Enable_url = "$ curl-o/dev/null -- data enable $ jenkins_url/job/$ j/enable"
Echo $ disable_url
$ ($ Disable_url)
Done


Of course, to enable a job, use "enable_url" in the script.

You can also use curl to create a Jenkins job. You can refer to the following articles:

Simple tutorial on using curl to operate hudson/Jenkins on a command line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.