0 votes
ago in Technology by (321k points)

How Jenkins jobs can be Triggered/Stopped/Controlled programmatically?

1 Answer

0 votes
ago by (321k points)

Jenkins Remote Access API can be used to do things like -

  • Retrieving information about jobs, views, nodes, builds, etc. from Jenkins for programmatic consumption.
  • Trigger a build (both parameterized & non-parameterized), stop/abort a build, enable/disable a Job, group/remove jobs into/from views, etc.
  • Create/copy/modify/delete jobs.

and many other programming language-specific functionalities. It has wrappers for main programming languages like - Python, Ruby & Java. It can be triggered via CURL as below -

Jobs without parameters

Simply an HTTP POST on JENKINS_URL/job/JOBNAME/build.

Jobs with parameters

Simple example - sending "String Parameters":

curl JENKINS_URL/job/JOB_NAME/buildWithParameters  --user USER:TOKEN --data id=123 --data verbosity=high

...