jenkins 2.x Remote access API的HTTPie实现
1.1、创建任务
http -v -f POST {JENKINS_INDEX}/createItem name=={JOB_NAME} @/path/to/config.xml --auth {USER_NAME}:{PASSWORD}

示例:

http -v -f POST http://localhost:8080/createItem name=={JOB_NAME} @/home/leleliu008/config.xml --auth liufupin:123456
1.2、启用任务
http -v POST {JENKINS_INDEX}/job/{JOB_NAME}/enable --auth {USER_NAME}:{PASSWORD}

示例:

http -v POST http://localhost:8080/job/testProject/enable --auth liufupin:123456
1.3、禁用任务
http -v POST {JENKINS_INDEX}/job/{JOB_NAME}/disable --auth {USER_NAME}:{PASSWORD}

示例:

http -v POST http://localhost:8080/job/testProject/disable --auth liufupin:123456
1.4、删除任务
http -v POST {JENKINS_INDEX}/job/{JOB_NAME}/doDelete --auth {USER_NAME}:{PASSWORD}

示例:

http -v POST http://localhost:8080/job/testProject/doDelete --auth liufupin:123456
1.5、构建任务
http -v POST {JENKINS_INDEX}/job/{JOB_NAME}/build --auth {USER_NAME}:{PASSWORD}

示例:

http -v POST http://localhost:8080/job/testProject/doDelete --auth liufupin:123456
1.6、触发任务的SCM检查
http -v POST {JENKINS_INDEX}/job/{JOB_NAME}/polling --auth {USER_NAME}:{PASSWORD}

示例:

http -v POST http://localhost:8080/job/testProject/polling --auth liufupin:123456
1.7、获取任务的描述
http -v GET {JENKINS_INDEX}/job/{JOB_NAME}/description --auth {USER_NAME}:{PASSWORD}

示例:

http -v GET http://localhost:8080/job/testProject/description --auth liufupin:123456
1.8、更新任务的描述
http -v -f POST {JENKINS_INDEX}/job/{JOB_NAME}/description description={DESCRIPTION} --auth {USER_NAME}:{PASSWORD}

示例:

http -v -f POST http://localhost:8080/job/testProject/description description=我是更新后的描述 --auth liufupin:123456
1.9、获取任务的配置
http -v GET {JENKINS_INDEX}/job/{JOB_NAME}/config.xml --auth {USER_NAME}:{PASSWORD}

示例:

http -v GET http://localhost:8080/job/testProject/config.xml --auth liufupin:123456
1.10、更新任务的配置
http -v POST {JENKINS_INDEX}/job/{JOB_NAME}/config.xml @/path/to/config.xml --auth {USER_NAME}:{PASSWORD}

示例:

http -v POST http://localhost:8080/job/testProject/config.xml @/home/leleliu008/config.xml --auth liufupin:123456