Mainframe Connector lets you trigger and monitor
Cloud Run jobs from your Mainframe. For example, you can use this
feature, to integrate your existing extraction, transformation, and loading
(ETL) tool with Mainframe Connector using Cloud Run
jobs.

This page discusses how you can perform the following tasks using
Mainframe Connector:

- **Trigger a Cloud Run job:** initiate a Cloud Run job from Mainframe Connector
- **View Cloud Run job logs:** view Cloud Run job logs locally on your Mainframe for monitoring
- **Cancel a Cloud Run job:** cancel an ongoing Cloud Run job

For more information about creating and managing Cloud Run jobs,
see [Cloud Run documentation](https://docs.cloud.google.com/run/docs.md.txt).

## Before you begin

- If you haven't already, then [install Mainframe Connector on your Mainframe](https://docs.cloud.google.com/mainframe-connector/docs/installation.md.txt).
- To run the Cloud Run commands, ensure that you assign the following roles to your user account:
  - [Cloud Run Invoker](https://docs.cloud.google.com/run/docs/reference/iam/roles.md.txt#run.invoker)
  - [Cloud Run Jobs Executor](https://docs.cloud.google.com/run/docs/reference/iam/roles.md.txt#run.jobsExecutor)
  - [Cloud Run Jobs Executor With Overrides](https://docs.cloud.google.com/run/docs/reference/iam/roles.md.txt#run.jobsExecutorWithOverrides)
  - [Cloud Run Viewer](https://docs.cloud.google.com/run/docs/reference/iam/roles.md.txt#run.viewer)
  - [Logs Viewer](https://docs.cloud.google.com/logging/docs/access-control.md.txt#logging.viewer) For more information about assigning roles to a user account, see [Managing access using IAM](https://docs.cloud.google.com/run/docs/securing/managing-access.md.txt).
- Set up [Application Default Credentials](https://docs.cloud.google.com/docs/authentication/provide-credentials-adc.md.txt).

## Run a Cloud Run job using Mainframe Connector

To run a Cloud Run job using Mainframe Connector,
follow these steps:

1. To trigger a Cloud Run job from your Mainframe, use the
   [`cloud run job execute` command](https://docs.cloud.google.com/mainframe-connector/docs/api-reference.md.txt#cloud-run-job-execute) from your Mainframe Job Control Language
   (JCL) file:

   ```
   //STEP01 EXEC BQSH
   //STDIN DD *
   cloud run job execute JOB_NAME
   /*
   ```

   Replace <var translate="no">JOB_NAME</var> with the Cloud Run job that you
   want to run.

   You can run the `cloud run job execute` command in the synchronous and
   asynchronous mode. If you want to trigger a job in synchronous mode and print
   job logs as the job progresses, then use the previous command with the
   `--tail_logs` flag.
2. To view the logs for a specific Cloud Run job execution, use
   the [`cloud run job logs` command](https://docs.cloud.google.com/mainframe-connector/docs/api-reference.md.txt#cloud-run-job-logs) from your Mainframe JCL file:

   ```
   //STEP01 EXEC BQSH
   //STDIN DD *
   cloud run job logs EXECUTION_ID
   /*
   ```

   Replace <var translate="no">EXECUTION_ID</var> with the execution ID of the
   Cloud Run job.
3. (Optional) To cancel a Cloud Run job, use the
   [`cloud run job cancel` command](https://docs.cloud.google.com/mainframe-connector/docs/api-reference.md.txt#cloud-run-job-cancel) from your Mainframe JCL file:

   ```
   Example JCL
   //STEP01 EXEC BQSH
   //STDIN DD *
   cloud run job cancel EXECUTION_ID
   /*
   ```

   Replace <var translate="no">EXECUTION_ID</var> with the execution ID of the
   Cloud Run job that you want to cancel.