jobs.<job_id>.services

1 minute read
On this page
jobs.<job_id>.services is a Preview feature.
A Preview feature:
  • Has not undergone end-to-end testing with CloudBees products.

  • Is provided without service-level agreements (SLA), and therefore does not include CloudBees' commitment to functionality or performance.

  • May impact other stable areas of the product when used.

  • May have limited documentation.

  • May not be feature-complete during the Preview period.

  • May graduate from Preview to a supported feature or be removed from the product.

  • May introduce breaking changes that prevent upgrades due to incompatibility with future development.

Product features and documentation are frequently updated. If you find an issue or have a suggestion, please contact CloudBees Support.

Use jobs.<job_id>.services to run a service in a separate container alongside the job for the duration of the run, providing functionality such as a database or application server.

Example usage

This example starts a PostgreSQL service, sets credentials with environment variables, and verifies connectivity with a simple SQL query.

apiVersion: automation.cloudbees.io/v1alpha1 kind: workflow name: Postgres service example on: push jobs: test: services: (1) postgres: (2) image: postgres:17-alpine3.20 (3) env: (4) POSTGRES_USER: testuser (5) POSTGRES_PASSWORD: testpassword POSTGRES_DB: testdb steps: - name: Run tests against postgres db uses: docker://postgres:17 env: DATABASE_URL: postgres://testuser:testpassword@localhost:5432/testdb (6) run: | psql -h localhost -U testuser -d testdb -c "SELECT 'Hello, PostgreSQL!' AS greeting;"
1 Declares service containers that run alongside the job.
2 Names the PostgreSQL service.
3 Pins the service image version.
4 Provides environment variables consumed by the postgres image at startup.
5 Sets default user, password, and database created by the service.
6 Connects to the service on localhost:5432 using the configured credentials.