turbaszek commented on a change in pull request #18184:
URL: https://github.com/apache/airflow/pull/18184#discussion_r706774724
##########
File path: airflow/providers/google/cloud/example_dags/example_cloud_build.py
##########
@@ -74,42 +108,148 @@
}
# [END howto_operator_create_build_from_repo_body]
+
with models.DAG(
"example_gcp_cloud_build",
default_args=dict(start_date=dates.days_ago(1)),
schedule_interval='@once',
- tags=['example'],
-) as dag:
+ tags=["example"],
+) as build_dag:
+
# [START howto_operator_create_build_from_storage]
create_build_from_storage = CloudBuildCreateBuildOperator(
- task_id="create_build_from_storage", project_id=GCP_PROJECT_ID,
body=create_build_from_storage_body
+ task_id="create_build_from_storage", project_id=GCP_PROJECT_ID,
build=create_build_from_storage_body
)
# [END howto_operator_create_build_from_storage]
# [START howto_operator_create_build_from_storage_result]
create_build_from_storage_result = BashOperator(
- bash_command="echo '{{
task_instance.xcom_pull('create_build_from_storage')['images'][0] }}'",
+ bash_command="echo '{{
task_instance.xcom_pull('create_build_from_storage')['results'] }}'",
task_id="create_build_from_storage_result",
)
# [END howto_operator_create_build_from_storage_result]
+ # [START howto_operator_create_build_from_repo]
create_build_from_repo = CloudBuildCreateBuildOperator(
- task_id="create_build_from_repo", project_id=GCP_PROJECT_ID,
body=create_build_from_repo_body
+ task_id="create_build_from_repo", project_id=GCP_PROJECT_ID,
build=create_build_from_repo_body
)
+ # [END howto_operator_create_build_from_repo]
+ # [START howto_operator_create_build_from_repo_result]
create_build_from_repo_result = BashOperator(
- bash_command="echo '{{
task_instance.xcom_pull('create_build_from_repo')['images'][0] }}'",
+ bash_command="echo '{{
task_instance.xcom_pull('create_build_from_repo')['results'] }}'",
task_id="create_build_from_repo_result",
)
+ # [END howto_operator_create_build_from_repo_result]
+
+ # [START howto_operator_list_builds]
+ list_builds = CloudBuildListBuildsOperator(
+ task_id="list_builds", project_id=GCP_PROJECT_ID, location="global"
+ )
+ # [END howto_operator_list_builds]
+
+ # [START howto_operator_create_build_without_wait]
+ create_build_without_wait = CloudBuildCreateBuildOperator(
+ task_id="create_build_without_wait",
+ project_id=GCP_PROJECT_ID,
+ build=create_build_from_repo_body,
+ wait=False,
+ )
+ # [END howto_operator_create_build_without_wait]
+
+ # [START howto_operator_cancel_build]
+ cancel_build = CloudBuildCancelBuildOperator(
+ task_id="cancel_build",
+ id="{{ task_instance.xcom_pull('create_build_without_wait')['id'] }}",
Review comment:
```suggestion
id= create_build_without_wait.output['id'],
```
Let's stick to the TaskFlow API here as we do in other examples.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]