1"use strict";(self.webpackChunkbatect_dev=self.webpackChunkbatect_dev||[]).push([[2933],{3905:function(e,t,n){n.d(t,{Zo:function(){return p},kt:function(){return b}});var a=n(7294);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t){if(null==e)return{};var n,a,i=function(e,t){if(null==e)return{};var n,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a<r.length;a++)n=r[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var l=a.createContext({}),o=function(e){var t=a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):s(s({},t),e)),n},p=function(e){var t=o(e.components);return a.createElement(l.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,i=e.mdxType,r=e.originalType,l=e.parentName,p=c(e,["components","mdxType","originalType","parentName"]),u=o(n),m=i,b=u["".concat(l,".").concat(m)]||u[m]||d[m]||r;return n?a.createElement(b,s(s({ref:t},p),{},{components:n})):a.createElement(b,s({ref:t},p))}));function b(e,t){var n=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var r=n.length,s=new Array(r);s[0]=m;var c={};for(var l in t)hasOwnProperty.call(t,l)&&(c[l]=t[l]);c.originalType=e,c[u]="string"==typeof e?e:i,s[1]=c;for(var o=2;o<r;o++)s[o]=n[o];return a.createElement.apply(null,s)}return a.createElement.apply(null,n)}m.displayName="MDXCreateElement"},3842:function(e,t,n){n.r(t),n.d(t,{assets:function(){return p},contentTitle:function(){return l},default:function(){return b},frontMatter:function(){return c},metadata:function(){return o},toc:function(){return u}});var a=n(7462),i=n(3366),r=(n(7294),n(3905)),s=["components"],c={title:"Buildkite"},l=void 0,o={unversionedId:"using-batect-with/ci/buildkite",id:"using-batect-with/ci/buildkite",title:"Buildkite",description:"Batect can run on any Buildkite agent that meets Batect's system requirements - chiefly Docker and a JVM.",source:"@site/docs/using-batect-with/ci/buildkite.md",sourceDirName:"using-batect-with/ci",slug:"/using-batect-with/ci/buildkite",permalink:"/docs/using-batect-with/ci/buildkite",draft:!1,editUrl:"https://github.com/batect/batect.dev/blob/main/docs/using-batect-with/ci/buildkite.md",tags:[],version:"current",frontMatter:{title:"Buildkite"},sidebar:"sidebar",previous:{title:"General advice",permalink:"/docs/using-batect-with/ci/general"},next:{title:"CircleCI",permalink:"/docs/using-batect-with/ci/circleci"}},p={},u=[{value:"Running with command evaluation disabled",id:"running-with-command-evaluation-disabled",level:2},{value:"Option 1: create step-specific shell scripts that invoke Batect",id:"option-1-create-step-specific-shell-scripts-that-invoke-batect",level:3},{value:"Option 2: create a wrapper script that takes the task name as an environment variable",id:"option-2-create-a-wrapper-script-that-takes-the-task-name-as-an-environment-variable",level:3}],d={toc:u},m="wrapper";function b(e){var t=e.components,n=(0,i.Z)(e,s);return(0,r.kt)(m,(0,a.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("p",null,"Batect can run on any Buildkite agent that meets Batect's ",(0,r.kt)("a",{parentName:"p",href:"/docs/getting-started/requirements"},"system requirements")," - chiefly Docker and a JVM."),(0,r.kt)("h2",{id:"running-with-command-evaluation-disabled"},"Running with command evaluation disabled"),(0,r.kt)("p",null,"Buildkite supports ",(0,r.kt)("a",{parentName:"p",href:"https://buildkite.com/docs/agent/v2/securing#disabling-command-eval"},"disabling command evaluation"),", which requires all build scripts to be\ninvoked without arguments and take any necessary input as environment variables. This prevents the use of the Batect wrapper script, as it expects to receive\nthe task name and other options as command line options."),(0,r.kt)("p",null,"There are two solutions to this:"),(0,r.kt)("h3",{id:"option-1-create-step-specific-shell-scripts-that-invoke-batect"},"Option 1: create step-specific shell scripts that invoke Batect"),(0,r.kt)("p",null,"In this scenario, you create multiple shell scripts, one for each step in Buildkite."),(0,r.kt)("p",null,"For example, let's say you have three steps in Buildkite: one for building, one for testing, and another for packaging. You would need to create a separate\nscript for each of these steps that invokes Batect, for example:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title="build.sh"',title:'"build.sh"'},"#! /usr/bin/env bash\n\nset -euo pipefail\n\n./batect build\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title="test.sh"',title:'"test.sh"'},"#! /usr/bin/env bash\n\nset -euo pipefail\n\n./batect unitTest\n./batect integrationTest\n./batect journeyTest\n")),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title="package.sh"',title:'"package.sh"'},"#! /usr/bin/env bash\n\nset -euo pipefail\n\n./batect package\n")),(0,r.kt)("h3",{id:"option-2-create-a-wrapper-script-that-takes-the-task-name-as-an-environment-variable"},"Option 2: create a wrapper script that takes the task name as an environment variable"),(0,r.kt)("p",null,"In this scenario, you create a single shell script and invoke it with different environment variable values for each step."),(0,r.kt)("p",null,"A script that executes the task given in the ",(0,r.kt)("inlineCode",{parentName:"p"},"BATECT_TASK")," environment variable is:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-bash",metastring:'title="batect-wrapper.sh"',title:'"batect-wrapper.sh"'},'#! /usr/bin/env bash\n\nset -euo pipefail\n\n./batect "$BATECT_TASK"\n')),(0,r.kt)("p",null,"Configure this in your Buildkite ",(0,r.kt)("inlineCode",{parentName:"p"},"pipeline.yml")," as follows:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-yaml",metastring:'title="pipeline.yml"',title:'"pipeline.yml"'},"steps:\n - label: Run build\n command: batect-wrapper.sh\n env:\n BATECT_TASK: build\n\n - label: Run unit tests\n command: batect-wrapper.sh\n env:\n BATECT_TASK: unitTest\n\n # ...and so on\n")))}b.isMDXComponent=!0}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.