Build Application with YAML

Tip
Learn more about: Build actions.

YAML Parameters for building applications

NameTypeDescription
action RequiredStringThe ID of the action.
type RequiredStringThe type of the action. Should be set to BUILD.
docker_image_name RequiredStringThe name of the Docker image.
docker_image_tag RequiredStringThe tag of the Docker image.
execute_commands RequiredString[]The commands that will be executed.
cached_dirsString[]The dependencies & directories to be cached and available to every execution in this pipeline.
working_directoryStringThe directory in which the pipeline filesystem will be mounted.
setup_commandsString[]The command that will be executed only on the first run.
shellStringThe name of the shell that will be used to execute commands. Can be one of SH (default) or BASH.
servicesService[]The containers with the services that will be attached to this environment. Available types: MYSQL, MONGO_DB, MARIADB, POSTGRE_SQL, REDIS, MEMCACHED, ELASTICSEARCH.
main_service_nameStringThe hostname of the container in which the action is run. The container will be available under this name in the docker network for services defined in the services field.
loginStringThe username required to connect to a private registry.
passwordStringThe password required to connect to a private registry.
registryStringThe url to the Docker registry or GCR. Required for Google GCR.
integrationStringThe ID of the integration. Available values: NONE, DOCKER_HUB, AMAZON_ECR, GOOGLE_GCR, GOOGLE_ARTIFACT_REGISTRY, GIT_HUB_CONTAINER_REGISTRY, OTHER.
regionStringThe name of the Amazon S3 region. Required for using the image from the Amazon ECR. The full list of regions is available here.
use_image_from_actionBooleanIf set to true the Docker image will be taken from action defined by docker_build_action_id or docker_build_action_name.
docker_build_action_idIntegerThe ID of the action which built the desired Docker image. If set to 0, the image will be taken from previous pipeline action. Can be used instead of docker_build_action_name.
docker_build_action_nameStringThe name of the action which built the desired Docker image. Can be used instead of docker_build_action_id.
execute_every_commandBooleanIf set to true, all commands will be executed regardless of the result of the previous command.
cache_base_imageBooleanIf set to true, the cached version of the image is used, instead of being pulled each time.
ignore_image_pull_failuresBooleanIf set to true, use cached image on timeouts (only for official images).
run_as_userStringAll build commands are run as the default user defined in the selected Docker image. Can be set to another username (on the condition that this user exists in the selected image).
image_locationStringThe location of the image used by the action. Available values: PUBLIC_REGISTRY, PRIVATE_REGISTRY, ACTION. If the value is other than ACTION, it must be provided together with the docker_registry field. If not provided, the system will automatically set it based on other data from the action.
docker_registryStringThe type of registry from which the image used by the action is retrieved. Available values: NONE, DOCKER_HUB, AMAZON_ECR, GOOGLE_GCR, GOOGLE_ARTIFACT_REGISTRY, GIT_HUB_CONTAINER_REGISTRY, OTHER. It must be provided together with image_location. If not specified, the system will automatically set it based on other data from the action.

YAML example for building apps

yaml
actions: - action: "Build application" type: "BUILD" docker_image_name: "library/ubuntu" docker_image_tag: "$tag" execute_commands: - "ls -al > ls.log" setup_commands: - "apt-get update -y" - "apt-get install -y wget" main_service_name: "my-app.svc" services: - type: "MYSQL" version: "5.7" - type: "MONGO_DB" version: "3.2.4" cached_dirs: - "/build/test" - "/bin/Debug" working_directory: "/buddy/my-repo-dir" shell: "SH" cache_base_image: true variables: - key: "tag" value: "latest"

Example – Using private image from Docker hub

YAML

yaml
actions: - action: "Build application" type: "BUILD" docker_image_name: "buddyworks/private_image" docker_image_tag: "latest" image_location: "PRIVATE_REGISTRY" docker_registry: "DOCKER_HUB" execute_commands: - "ls -al > ls.log" integration: "my_integration" variables: - key: "top_secret_password" value: "secure!14ivLMxPgv7TX6c9+ITX/g==" encrypted: true description: "The password for docker registry."

Example – Using image from private registry

YAML

yaml
actions: - action: "Build application" type: "BUILD" docker_image_name: "buddyworks/private_image" docker_image_tag: "latest" image_location: "PRIVATE_REGISTRY" docker_registry: "OTHER" execute_commands: - "ls -al > ls.log" login: "buddyworks" registry: "my.registry.com" password: "${top_secret_password}" variables: - key: "top_secret_password" value: "secure!14ivLMxPgv7TX6c9+ITX/g==" encrypted: true description: "The password for docker registry."

Example – Using image from Google Container Registry

YAML

yaml
actions: - action: "Build application" type: "BUILD" docker_image_name: "tokyo-house-147623/private_image" docker_image_tag: "latest" image_location: "PRIVATE_REGISTRY" docker_registry: "GCR" execute_commands: - "ls -al > ls.log" registry: "my.gcr.com" integration: "my_integration"

Example – Using image from Amazon ECR

YAML

yaml
actions: - action: "Build application" type: "BUILD" docker_image_name: "private_image" docker_image_tag: "latest" image_location: "PRIVATE_REGISTRY" docker_registry: "ECR" execute_commands: - "ls -al > ls.log" region: "us-east-1" integration: "my_integration"

Example – Using image from Github container registry

yaml
actions: - action: "Build application" type: "BUILD" docker_image_name: "private_image" docker_image_tag: "latest" image_location: "PRIVATE_REGISTRY" docker_registry: "GIT_HUB_CONTAINER_REGISTRY" execute_commands: - "ls -al > ls.log" integration: "my_integration"

Example – Using image built in previous action

YAML

yaml
actions: - action: "Build application" type: "BUILD" docker_build_action_id: 0 image_location: "ACTION" execute_commands: - "ls -al > ls.log"

Using the build action services

Parameters of the service

NameTypeDescription
type RequiredStringThe type of the attached service. Can be one of MYSQL, MARIADB, REDIS, MONGO_DB, POSTGRE_SQL, CASSANDRA, MEMCACHED, ELASTICSEARCH, SELENIUM_CHROME, SELENIUM_FIREFOX, GANACHE, RABBITMQ, CUSTOM.
connection RequiredConnectionThe service’s connection details.
persistentBooleanIf set to true, the database content will be cached between executions. Available when type is set to MYSQL, MARIADB, REDIS, MONGO_DB, POSTGRE_SQL, CASSANDRA or GANACHE.
versionStringThe version of the predefined service’s base image. Required for every type except for CUSTOM.
dump_pathStringThe path to the SQL dump file that will be used to populate service’s database. Available when type is set to MARIADB, POSTGRE_SQL or MYSQL.
docker_image_nameStringThe name of the Docker image. Available when type is set to CUSTOM.
docker_image_tagStringThe tag of the Docker image. Available when type is set to CUSTOM.
registryStringThe url to the Docker registry or GCR. Available when type is set to CUSTOM.
loginStringWhen type is set to custom, this is the username required to connect to a private registry or GCR.
passwordStringWhen type is set to custom, this is the password required to connect to a private registry or GCR.
working_directoryStringThe directory in which the commands are executed. Available when type is set to CUSTOM.
inline_commandsStringThe command that will be executed upon running the container with the service. Available when type is set to CUSTOM.
volume_mappingsString[]The path preceding the colon is the filesystem path (the folder from the filesystem to be mounted in the container). The path after the colon is the container path (the path in the container, where this filesystem will be located).
cached_dirsString[]The additional container’s directories that will be cached between executions. Available when typeis set to CUSTOM.
use_image_from_actionBooleanIf set to true the Docker image will be taken from action defined by docker_build_action_id or docker_build_action_name. Available when type is set to CUSTOM.
docker_build_action_idIntegerThe ID of the action which built the desired Docker image. If set to 0, the image will be taken from previous pipeline action. Can be used instead of docker_build_action_name.
docker_build_action_nameStringThe name of the action which built the desired Docker image. Can be used instead of docker_build_action_id.
integrationIntegerThe ID of the integration. Required for using the image from the Amazon ECR and Docker Hub. Available when type is set to CUSTOM.
regionStringThe name of the Amazon S3 region. Available when type is set to CUSTOM. Required for using the image from the Amazon ECR. The full list of regions is available here.
wait_for_portIntegerBuild commands in the main container will be executed only if the entered service port is responding. Available when type is set to CUSTOM.
execute_every_commandBooleanIf set to true all commands will be executed regardless of the result of the previous command.
pass_variablesBooleanAllow passing variables to this service.
entrypointStringDefault command to execute at runtime. Overwrites the default entrypoint set by the image.
ignore_image_pull_failuresBooleanIf set to true, use cached image on timeouts (only for official images). Available when type is set to CUSTOM.
cache_base_imageBooleanIf set to true, the cached version of the image is used, instead of being pulled each time. Available when type is set to CUSTOM.
run_as_userStringAll build commands are run as the default user defined in the selected Docker image. Can be set to another username (on the condition that this user exists in the selected image). Available when type is set to CUSTOM.
image_locationStringThe location of the image used by the action. Available values: PUBLIC_REGISTRY, PRIVATE_REGISTRY, ACTION. If the value is other than ACTION, it must be provided together with the docker_registry field. If not provided, the system will automatically set it based on other data from the action.
docker_registryStringThe type of registry from which the image used by the action is retrieved. Available values: NONE, DOCKER_HUB, AMAZON_ECR, GOOGLE_GCR, GOOGLE_ARTIFACT_REGISTRY, OTHER. It must be provided together with image_location. If not specified, the system will automatically set it based on other data from the action.

Parameters of the connection item

NameTypeDescription
host RequiredStringThe hostname that will be available within the docker network upon the execution.
dbStringThe initial database name. Available when type is set to MARIADB, POSTGRE_SQL or MYSQL.
portIntegerThe service’s connection port.
userStringDefines the username used in the desired service. Available and required when type is set to MYSQL, MARIADB, POSTGRE_SQL or RABBITMQ.
passwordStringDefines the password used in the desired service. Available and required when type is set to MYSQL, MARIADB, POSTGRE_SQL or RABBITMQ.

Example

YAML

yaml
actions: - action: "Build application" type: "BUILD" docker_image_name: "library/ubuntu" docker_image_tag: "latest" execute_commands: - "ls" services: - type: "CUSTOM" connection: host: "custom.service" use_image_from_action: true wait_for_port: 1234 working_directory: "/buddy/git-repo" volume_mappings: - "/:/buddy/mount/directory" cached_dirs: - "/var/data/" pass_variables: true entrypoint: "/bin/sh" - type: "MYSQL" version: "5.7" persistent: true connection: host: "mysql" port: 3306 user: "root" password: "root" pass_variables: true - type: "MARIADB" version: "10.1.16" persistent: true connection: host: "mariadb" port: 3306 user: "root" password: "root" pass_variables: true - type: "REDIS" version: "3.2.1" persistent: true connection: host: "redis" port: 6379 pass_variables: true - type: "MONGO_DB" version: "3.2.4" persistent: true connection: host: "mongo" port: 27017 pass_variables: true - type: "POSTGRE_SQL" version: "9.5.3" persistent: true connection: host: "postgres" port: 5432 user: "root" password: "root" pass_variables: true - type: "CASSANDRA" version: "3.11" persistent: true connection: host: "cassandra" port: 9042 pass_variables: true - type: "MEMCACHED" version: "1.4.29" persistent: false connection: host: "memcached" port: 11211 pass_variables: true - type: "ELASTICSEARCH" version: "2.3.4" persistent: false connection: host: "elasticsearch" port: 9200 pass_variables: true - type: "SELENIUM_FIREFOX" version: "3.0.1" persistent: false connection: host: "selenium-ff" port: 4444 pass_variables: true - type: "SELENIUM_CHROME" version: "3.0.1" persistent: false connection: host: "selenium-ch" port: 4444 pass_variables: true - type: "GANACHE" version: "latest" persistent: true connection: host: "ganache" port: 8545 gas_price: 20000000000 gas_limit: 90000 accounts: - "0xfd7ac8b32e8a2391cad323efd7b162d77dd9ca67806d09877552c38b618713a5:1000000000000000000" pass_variables: true - type: "RABBIT_MQ" version: "3.7.8" persistent: true connection: host: "rabbitmq" port: 5672 user: "guest" password: "guest" pass_variables: true

Last modified on Oct 4, 2024