{"id":29272,"date":"2023-11-13T16:00:11","date_gmt":"2023-11-13T15:00:11","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=29272"},"modified":"2024-04-18T09:10:21","modified_gmt":"2024-04-18T07:10:21","slug":"cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/","title":{"rendered":"Cloudbees CD\/RO, send and receive parameters with bash \/ Ansible scripts"},"content":{"rendered":"\n<p>Sending a pipeline parameter to a bash or Ansible script is easy, but the reverse is less obvious.<\/p>\n\n\n\n<p>In this article, we&#8217;ll look at how to return parameters from an Ansible script to a Cloudbees CD\/RO job.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-the-easy-way\">The easy way<\/h2>\n\n\n\n<p>You can easily transfer a parameter from the Cloudbees CD\/RO procedure to an Ansible script. Simply pass the parameter or variable to the command to execute:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ansible-playbook playbooks\/pipeline_action.yml -l $&#091;ansibleHost] -e myAnsibleParam=\"${myCDParams}\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-types-of-arguments\">Types of arguments<\/h3>\n\n\n\n<p>Many kinds of data can be used to transfer values to Ansible script:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Input Parameter, from pipeline or procedure form.  Exemple: $[myParameter] <\/li>\n\n\n\n<li>Properties, from any object in Cloudbees CD\/RO. Exemple: $[\/projects\/my_project_name\/my_property]<\/li>\n\n\n\n<li>Variable, define on procedure runtime.  Exemple: ${my_varaibles}<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-getting-data-the-hard-way\">Getting data, the hard way<\/h2>\n\n\n\n<p>Sending data is easy, but receiving data from a script to use it into a pipeline is more complicated.<\/p>\n\n\n\n<p>To obtain data from a script, you need to run a script that creates a property for the job. After that, the property can be used in the procedure run.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-running-a-script-to-get-data\">Running a script to get data<\/h3>\n\n\n\n<p>Simply run a script, such as:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ansible-playbook playbooks\/get_values.yml <\/code><\/pre>\n\n\n\n<p>Parameter transfer takes place inside the script using the Cloudbees CD\/RO command ectool:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>- name: Define environment\n  command: \"ectool setProperty \/myJob\/environmentCreated {{ success_state }}\"<\/code><\/pre>\n\n\n\n<p>This task defines an &#8220;environmentCreated&#8221; property in the job scope with as value for the ansible variable success_state.<\/p>\n\n\n\n<p>You can create as many properties as you need.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-using-the-property\">Using the property<\/h3>\n\n\n\n<p>Like all properties, it can be accessed using $[\u2026]<br>Example: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if &#091;&#091; \"$&#091;\/myJob\/environmentCreated]\" == \"success\" ]]; then\n   ...\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>Retrieving values from a script in Cloudbees pipelines is perfectly possible using ectool, however, scripts need to be adapted to define properties that can be used in procedures.<\/p>\n\n\n\n<p>To learn more about properties, see the <a href=\"https:\/\/docs.cloudbees.com\/docs\/cloudbees-cd\/latest\/automation-platform\/properties\">Cloudbees CD\/RO documentation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sending a pipeline parameter to a bash or Ansible script is easy, but the reverse is less obvious. In this article, we&#8217;ll look at how to return parameters from an Ansible script to a Cloudbees CD\/RO job. The easy way You can easily transfer a parameter from the Cloudbees CD\/RO procedure to an Ansible script. [&hellip;]<\/p>\n","protected":false},"author":72,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1321,1320],"tags":[2600,3158,2667,2981],"type_dbi":[],"class_list":["post-29272","post","type-post","status-publish","format-standard","hentry","category-ansible","category-devops","tag-ansible-2","tag-cloudbees-cd","tag-devops-2","tag-pipeline"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Cloudbees CD\/RO, send and receive parameters with bash \/ Ansible scripts - dbi Blog<\/title>\n<meta name=\"description\" content=\"How to send and receive parameters between Cloudbees CD\/RO procedure steps and bash \/ ansible scripts.\" \/>\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.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cloudbees CD\/RO, send and receive parameters with bash \/ Ansible scripts\" \/>\n<meta property=\"og:description\" content=\"How to send and receive parameters between Cloudbees CD\/RO procedure steps and bash \/ ansible scripts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-13T15:00:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-18T07:10:21+00:00\" \/>\n<meta name=\"author\" content=\"Nicolas Meunier\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nicolas Meunier\" \/>\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.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/\"},\"author\":{\"name\":\"Nicolas Meunier\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/2e08c09a2f083004587b54128684fefe\"},\"headline\":\"Cloudbees CD\\\/RO, send and receive parameters with bash \\\/ Ansible scripts\",\"datePublished\":\"2023-11-13T15:00:11+00:00\",\"dateModified\":\"2024-04-18T07:10:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/\"},\"wordCount\":288,\"commentCount\":0,\"keywords\":[\"Ansible\",\"Cloudbees Cd\",\"devops\",\"Pipeline\"],\"articleSection\":[\"Ansible\",\"DevOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/\",\"name\":\"Cloudbees CD\\\/RO, send and receive parameters with bash \\\/ Ansible scripts - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"datePublished\":\"2023-11-13T15:00:11+00:00\",\"dateModified\":\"2024-04-18T07:10:21+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/2e08c09a2f083004587b54128684fefe\"},\"description\":\"How to send and receive parameters between Cloudbees CD\\\/RO procedure steps and bash \\\/ ansible scripts.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cloudbees CD\\\/RO, send and receive parameters with bash \\\/ Ansible scripts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/2e08c09a2f083004587b54128684fefe\",\"name\":\"Nicolas Meunier\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g\",\"caption\":\"Nicolas Meunier\"},\"description\":\"Nicolas Meunier has more than 20 years of experience in IT web technologies as well as in development. He is specialized in Cloud solutions such as CI\\\/CD. His expertise also includes Kubernetes, Docker, Jenkins-X and Azure Devops. Florence Porret (FP is IT Consultant in Cloud solutions. Prior to joining dbi services, Nicolas Meunier was developer and maintainer of a CI\\\/CD pipelines at CEGID in Paris. He also worked as Lead Developer at KPMG. Florence Porret (FP holds a superior technical diploma in IT development. His branch-related experience covers software and cloud platform architecture.\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/nicolasmeunier\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Cloudbees CD\/RO, send and receive parameters with bash \/ Ansible scripts - dbi Blog","description":"How to send and receive parameters between Cloudbees CD\/RO procedure steps and bash \/ ansible scripts.","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.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/","og_locale":"en_US","og_type":"article","og_title":"Cloudbees CD\/RO, send and receive parameters with bash \/ Ansible scripts","og_description":"How to send and receive parameters between Cloudbees CD\/RO procedure steps and bash \/ ansible scripts.","og_url":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/","og_site_name":"dbi Blog","article_published_time":"2023-11-13T15:00:11+00:00","article_modified_time":"2024-04-18T07:10:21+00:00","author":"Nicolas Meunier","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Nicolas Meunier","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/"},"author":{"name":"Nicolas Meunier","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe"},"headline":"Cloudbees CD\/RO, send and receive parameters with bash \/ Ansible scripts","datePublished":"2023-11-13T15:00:11+00:00","dateModified":"2024-04-18T07:10:21+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/"},"wordCount":288,"commentCount":0,"keywords":["Ansible","Cloudbees Cd","devops","Pipeline"],"articleSection":["Ansible","DevOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/","url":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/","name":"Cloudbees CD\/RO, send and receive parameters with bash \/ Ansible scripts - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2023-11-13T15:00:11+00:00","dateModified":"2024-04-18T07:10:21+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe"},"description":"How to send and receive parameters between Cloudbees CD\/RO procedure steps and bash \/ ansible scripts.","breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/cloudbees-cd-ro-send-and-receive-parameters-with-bash-ansible-scripts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Cloudbees CD\/RO, send and receive parameters with bash \/ Ansible scripts"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/2e08c09a2f083004587b54128684fefe","name":"Nicolas Meunier","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cc2139acc6c64bddf3827e2faaaa70f227faafc288457fc351a4a836813112a8?s=96&d=mm&r=g","caption":"Nicolas Meunier"},"description":"Nicolas Meunier has more than 20 years of experience in IT web technologies as well as in development. He is specialized in Cloud solutions such as CI\/CD. His expertise also includes Kubernetes, Docker, Jenkins-X and Azure Devops. Florence Porret (FP is IT Consultant in Cloud solutions. Prior to joining dbi services, Nicolas Meunier was developer and maintainer of a CI\/CD pipelines at CEGID in Paris. He also worked as Lead Developer at KPMG. Florence Porret (FP holds a superior technical diploma in IT development. His branch-related experience covers software and cloud platform architecture.","url":"https:\/\/www.dbi-services.com\/blog\/author\/nicolasmeunier\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/29272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=29272"}],"version-history":[{"count":12,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/29272\/revisions"}],"predecessor-version":[{"id":32694,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/29272\/revisions\/32694"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=29272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=29272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=29272"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=29272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}