{"id":528,"date":"2017-02-24T12:14:09","date_gmt":"2017-02-24T12:14:09","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2017\/02\/24\/jenkins-remote-access-api-example\/"},"modified":"2021-02-27T09:49:37","modified_gmt":"2021-02-27T09:49:37","slug":"jenkins-remote-access-api-example","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/","title":{"rendered":"Jenkins Remote access API Example | Jenkins Tutorial"},"content":{"rendered":"<div><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3002 size-full\" src=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e.png\" alt=\"jenkins-remote-access-api-example\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e.png 600w, https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/div>\n<div><\/div>\n<div><strong>Jenkins Remote access API Example<\/strong><\/div>\n<div><\/div>\n<div><strong>Jenkins provides machine-consumable remote access API to its functionalities. Currently it comes in three flavors:<\/strong><\/div>\n<div><\/div>\n<div>XML<\/div>\n<div>JSON with JSONP support<\/div>\n<div>Python<\/div>\n<div><\/div>\n<div>Remote access API is offered in a REST-like style. That is, there is no single entry point for all features, and instead they are available under the &#8220;&#8230;\/api\/&#8221; URL where &#8220;&#8230;&#8221; portion is the data that it acts on.<\/div>\n<div><\/div>\n<div>For example, if your Jenkins installation sits at http:\/\/ci.jruby.org\/, visiting http:\/\/ci.jruby.org\/api\/ will show just the top-level API features available \u2013 primarily a listing of the configured jobs for this Jenkins instance.<\/div>\n<div><\/div>\n<div>Or if you want to access information about a particular build, e.g. http:\/\/ci.jruby.org\/job\/jruby-base\/lastSuccessfulBuild\/, then go to http:\/\/ci.jruby.org\/job\/jruby-base\/lastSuccessfulBuild\/api\/ and you&#8217;ll see the list of functionalities for that build.<\/div>\n<div><\/div>\n<div><strong>Remote API can be used to do things like these:<\/strong><\/div>\n<div><\/div>\n<div>Retrieve information from Jenkins for programmatic consumption.<\/div>\n<div>trigger a new build<\/div>\n<div>create\/copy jobs<\/div>\n<div><\/div>\n<div><\/div>\n<div>Jobs with parameters, Also see Parameterized Build.<\/div>\n<div>Simple example &#8211; sending &#8220;String Parameters&#8221;:<\/div>\n<div>curl -X POST JENKINS_URL\/job\/JOB_NAME\/build \\<\/div>\n<div>\u00a0 &#8211;data token=TOKEN \\<\/div>\n<div>\u00a0 &#8211;data-urlencode json='{&#8220;parameter&#8221;: [{&#8220;name&#8221;:&#8221;id&#8221;, &#8220;value&#8221;:&#8221;123&#8243;}, {&#8220;name&#8221;:&#8221;verbosity&#8221;, &#8220;value&#8221;:&#8221;high&#8221;}]}&#8217;<\/div>\n<div><\/div>\n<div><strong>Check Jenkins Job Status via REST API<\/strong><\/div>\n<div><\/div>\n<div>job_status=`curl https:\/\/jenkins\/view\/job\/other-job\/lastBuild\/api\/json | grep &#8220;\\&#8221;result\\&#8221;:\\&#8221;SUCCESS\\&#8221;&#8221;`<\/div>\n<pre>if [ -n \"$job_status\" ] then \u00a0 \u00a0 # Run your script commands here else \u00a0 echo \"BUILD FAILURE: Other build is unsuccessful or status could not be obtained.\" \u00a0 exit 1 fi<\/pre>\n<div><\/div>\n<div><\/div>\n<div><strong>How to restart Jenkins manually?<\/strong><\/div>\n<div><\/div>\n<div>To restart Jenkins manually, you can use either of the following commands:<\/div>\n<div>(jenkins_url)\/safeRestart &#8211; Allows all running jobs to complete. New jobs will remain in the queue to run after the restart is complete.<\/div>\n<div><\/div>\n<div>(jenkins_url)\/restart &#8211; Forces a restart without waiting for builds to complete.<\/div>\n<div><\/div>\n<div><strong>Reference<\/strong><\/div>\n<div><a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Remote+access+API\" target=\"_blank\" rel=\"noopener\">https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Remote+access+API<\/a><\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Jenkins Remote access API Example Jenkins provides machine-consumable remote access API to its functionalities. Currently it comes in three flavors: [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":3002,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[42],"tags":[380,1056,519,145,822,383,1057,1058],"class_list":["post-528","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jenkins","tag-access","tag-api","tag-example","tag-jenkins","tag-jenkins-tutorial","tag-remote","tag-remote-access-api","tag-remote-api"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Jenkins Remote access API Example | Jenkins Tutorial - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Jenkins Remote access API Example | Jenkins Tutorial - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Jenkins Remote access API Example Jenkins provides machine-consumable remote access API to its functionalities. Currently it comes in three flavors: [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2017-02-24T12:14:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-02-27T09:49:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"scmgalaxy K\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"scmgalaxy K\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/\"},\"author\":{\"name\":\"scmgalaxy K\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"headline\":\"Jenkins Remote access API Example | Jenkins Tutorial\",\"datePublished\":\"2017-02-24T12:14:09+00:00\",\"dateModified\":\"2021-02-27T09:49:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/\"},\"wordCount\":294,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/jenkins-remote-access-api-e.png\",\"keywords\":[\"access\",\"API\",\"Example\",\"Jenkins\",\"Jenkins Tutorial\",\"Remote\",\"Remote access API\",\"Remote API\"],\"articleSection\":[\"Jenkins\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/\",\"name\":\"Jenkins Remote access API Example | Jenkins Tutorial - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/jenkins-remote-access-api-e.png\",\"datePublished\":\"2017-02-24T12:14:09+00:00\",\"dateModified\":\"2021-02-27T09:49:37+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/jenkins-remote-access-api-e.png\",\"contentUrl\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/jenkins-remote-access-api-e.png\",\"width\":600,\"height\":400,\"caption\":\"jenkins-remote-access-api-example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/jenkins-remote-access-api-example\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Jenkins Remote access API Example | Jenkins Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/fc12ad190f540e79460243c81148d102\",\"name\":\"scmgalaxy K\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g\",\"caption\":\"scmgalaxy K\"},\"sameAs\":[\"http:\\\/\\\/www.DevOpsSchool.com\"],\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/scmgalaxy\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Jenkins Remote access API Example | Jenkins Tutorial - scmGalaxy","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/","og_locale":"en_US","og_type":"article","og_title":"Jenkins Remote access API Example | Jenkins Tutorial - scmGalaxy","og_description":"Jenkins Remote access API Example Jenkins provides machine-consumable remote access API to its functionalities. Currently it comes in three flavors: [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/","og_site_name":"scmGalaxy","article_published_time":"2017-02-24T12:14:09+00:00","article_modified_time":"2021-02-27T09:49:37+00:00","og_image":[{"width":600,"height":400,"url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e.png","type":"image\/png"}],"author":"scmgalaxy K","twitter_card":"summary_large_image","twitter_misc":{"Written by":"scmgalaxy K","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/"},"author":{"name":"scmgalaxy K","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"headline":"Jenkins Remote access API Example | Jenkins Tutorial","datePublished":"2017-02-24T12:14:09+00:00","dateModified":"2021-02-27T09:49:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/"},"wordCount":294,"commentCount":1,"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e.png","keywords":["access","API","Example","Jenkins","Jenkins Tutorial","Remote","Remote access API","Remote API"],"articleSection":["Jenkins"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/","name":"Jenkins Remote access API Example | Jenkins Tutorial - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/#primaryimage"},"image":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e.png","datePublished":"2017-02-24T12:14:09+00:00","dateModified":"2021-02-27T09:49:37+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/#primaryimage","url":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e.png","contentUrl":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2017\/02\/jenkins-remote-access-api-e.png","width":600,"height":400,"caption":"jenkins-remote-access-api-example"},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/jenkins-remote-access-api-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Jenkins Remote access API Example | Jenkins Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/fc12ad190f540e79460243c81148d102","name":"scmgalaxy K","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b902ea8c77ee0a326c112f29d0edf51b7c3e1cd05c4fb92a810177e9c3f12a9?s=96&d=mm&r=g","caption":"scmgalaxy K"},"sameAs":["http:\/\/www.DevOpsSchool.com"],"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/scmgalaxy\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=528"}],"version-history":[{"count":3,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/528\/revisions"}],"predecessor-version":[{"id":3234,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/528\/revisions\/3234"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media\/3002"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}