jenkins通过命令行启动其他job

1.使用curl

curl -X POST http://localhost:8080/jenkins/job/demo2/build –user admin:123456

2.使用jenkins CLI,需要先下载jenkins-cli.jar包

先下载jar包,

wget http://localhost:8080/jenkins/jnlpJars/jenkins-cli.jar

java -jar jenkins-cli.jar -s http://localhost:8080/jenkins  build demo2 -p id=123 -p name=autotest –username admin2 –password 123456

3.使用python api

安装pip install python-jenkins

>>> import jenkins

>>> jenkins.Jenkins(“http://localhost:8080/jenkins”,”admin”,”123456″)

<jenkins.Jenkins object at 0x000000000293BB00>

>>> jenkinobj=jenkins.Jenkins(“http://localhost:8080/jenkins”,”admin”,”123456″)

>>> jenkinobj.build_job

<bound method Jenkins.build_job of <jenkins.Jenkins object at 0x00000000033A7390>>

>>> jenkinobj.build_job(“demo2”)

带参数的:

>>> jenkinobj.build_job(“demo2”,dict1)

21

    原文作者:非鱼2018
    原文地址: https://www.jianshu.com/p/249003168860
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞