{"id":352,"date":"2014-05-27T00:00:00","date_gmt":"2014-05-27T00:00:00","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2014\/05\/27\/ways-to-login-jenkins-using-command-line\/"},"modified":"2021-11-19T09:28:49","modified_gmt":"2021-11-19T09:28:49","slug":"ways-to-login-jenkins-using-command-line","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/ways-to-login-jenkins-using-command-line\/","title":{"rendered":"What are the ways to Login Jenkins using Command line ?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3719 size-full\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2014\/05\/jenkins-login-command-line.png\" alt=\"login-jenkins-using-command-line\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2014\/05\/jenkins-login-command-line.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2014\/05\/jenkins-login-command-line-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><strong>Ways to Login Jenkins using Command line<\/strong><\/p>\n<p><strong>&amp;<\/strong><\/p>\n<p><strong>Way to trigger Jenkins job using Command line or script<\/strong><\/p>\n<h3>Wget<\/h3>\n<p>Note: If you are using wget 1.11, you might need to use the following options:<\/p>\n<div class=\"code panel\" style=\"border-width: 1px;\">\n<div class=\"codeContent panelContent\">\n<pre class=\"code-java\">&nbsp;wget --auth-no-challenge --http-user=user --http-password=apiToken http:<span class=\"code-comment\">\/\/jenkins.yourcompany.com\/job\/your_job\/build?token=TOKEN<\/span><\/pre>\n<\/div>\n<\/div>\n<p>With wget 1.10.x the following is enough (but will not work with 1.11.x) :<\/p>\n<div class=\"code panel\" style=\"border-width: 1px;\">\n<div class=\"codeContent panelContent\">\n<pre class=\"code-java\">&nbsp;wget http:<span class=\"code-comment\">\/\/user:apiToken@jenkins.yourcompany.com\/job\/your_job\/build?token=TOKEN\n<\/span><\/pre>\n<p>ex &#8211;&nbsp;wget http:\/\/yourserver\/job\/MyJobname\/build?delay=0sec<\/p>\n<h3>CURL<\/h3>\n<p><strong>Without authentication:<\/strong><\/p>\n<p><code>$ curl http:\/\/jenkins:8080\/job\/my%20job\/build [ HTML page saying \"Authentication required\" ] <\/code><\/p>\n<p><strong>With authentication:<\/strong><\/p>\n<p><code>$ curl --user dbacher:$MY_API_TOKEN http:\/\/jenkins:8080\/job\/my%20job\/build [ returns nothing and the build starts ] <\/code><\/p>\n<pre class=\"code-java\">curl -X POST http:\/\/server\/view\/name\/job\/jobname\/build?delay=0sec --user 1019352:61bb8531292794315f5dda8113548630<\/pre>\n<\/div>\n<\/div>\n<p>Login Jenkins using groovy script or Perl Script or Java, please refer the reference page&#8230;<\/p>\n<p><strong>Reference:<\/strong><br>\n<a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Authenticating+scripted+clients\" target=\"_blank\" rel=\"noopener\">https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Authenticating+scripted+clients<\/a><\/p>\n<p><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><\/p>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_17176\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_30869\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_17176\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Ways to Login Jenkins using Command line &amp; Way to trigger Jenkins job using Command line or script Wget Note: If you are using wget 1.11, you might need to use the following options: &nbsp;wget &#8211;auth-no-challenge &#8211;http-user=user &#8211;http-password=apiToken http:\/\/jenkins.yourcompany.com\/job\/your_job\/build?token=TOKEN With wget 1.10.x the following is enough (but will not work with 1.11.x) : &nbsp;wget http:\/\/user:apiToken@jenkins.yourcompany.com\/job\/your_job\/build?token=TOKEN&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3719,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[42],"tags":[824,2233,1122,545,145,830,2230,2234,2232,822,897,1802,2231,593,213,1452,670],"class_list":["post-352","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jenkins","tag-command-line","tag-commands-for-login-in-jenkins","tag-guide","tag-how","tag-jenkins","tag-jenkins-guide","tag-jenkins-login","tag-jenkins-login-by-command-line","tag-jenkins-login-through-command-line","tag-jenkins-tutorial","tag-login","tag-login-jenkins","tag-login-jenkins-using-command-line","tag-process","tag-tutorial","tag-ways","tag-what"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=352"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/352\/revisions"}],"predecessor-version":[{"id":25847,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/352\/revisions\/25847"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3719"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}