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