jobs.<job_id>.services.<service_id>.image

2 minute read
jobs.<job_id>.services.<service_id>.image 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.<service_id>.image to specify an image.

Specify a Docker image

Use jobs.<job_id>.services.<service_id>.image to add a Docker image to a workflow job.

To allow the steps within a job to access the service instances, use localhost or 127.0.0.1 as the host, and the corresponding port for the service.
apiVersion: automation.cloudbees.io/v1alpha1 kind: workflow name: MySQL service example on: push jobs: test: services: my-service: image: mysql:8.0 env: MYSQL_ROOT_PASSWORD: examplepassword MYSQL_DATABASE: exampledb args: "--default-authentication-plugin=mysql_native_password" steps: - name: Wait for MySQL service to be ready uses: docker://mysql:8.0 run: | until mysqladmin ping -h 127.0.0.1 --silent; do echo "Waiting for database connection..." sleep 2 done env: MYSQL_PWD: examplepassword - name: Run a query uses: docker://mysql:8.0 run: | echo "SHOW DATABASES;" | mysql -u root -h 127.0.0.1 env: MYSQL_PWD: examplepassword

Specify a private image

Use jobs.<job_id>.services.<service_id>.image to add an image stored on a private repository to a workflow job. To learn more about using private images, refer to:

Example usage

In the following example, an image stored in Amazon Web Services (AWS) Elastic Container Registry (ECR) is added to the workflow job.

apiVersion: automation.cloudbees.io/v1alpha1 kind: workflow name: AWS ECR example on: push jobs: my-job: permissions: scm-token-own: read id-token: write services: my-service: image: mysql:8.0 env: MYSQL_ROOT_PASSWORD: {{ secrets.MYSQL_PASSWORD }} MYSQL_DATABASE: exampledb args: "--default-authentication-plugin=mysql_native_password" steps: - name: Checkout uses: https://github.com/cloudbees-io/checkout@v1 - name: Log in to AWS uses: https://github.com/cloudbees-io/configure-aws-credentials@v1 id: aws-login with: aws-region: us-east-1 role-to-assume: {{vars.AWS_ROLE }} role-duration-seconds: "3600" - name: Wait for MySQL service to be ready uses: {{ secrets.AWS_ECR_HOSTNAME }} run: | until mysqladmin ping -h 127.0.0.1 --silent; do echo "Waiting for database connection..." sleep 2 done env: MYSQL_PWD: {{ secrets.MYSQL_PASSWORD }} - name: Run a query uses: {{ secrets.AWS_ECR_HOSTNAME }} run: | echo "SHOW DATABASES;" | mysql -u root -h 127.0.0.1 env: MYSQL_PWD: {{ secrets.MYSQL_PASSWORD }}