title: Apache Airflow Xcom Pull from dynamic task name
body: <p>I have successfully created dynamic tasks in a DAG (Bash and Docker Operators) but I'm having a hard time passing those dynamically created tasks to xcom_pull to grab data.</p>
  
  <pre><code>for i in range(0, max_tasks):
      task_scp_queue = BashOperator(task_id="scp_queue_task_{}".format(i), bash_command="""python foo""", retries=3, dag=dag, pool="scp_queue_pool", queue="foo", provide_context=True, xcom_push=True) # Pull the manifest ID from the previous task via xcom'
  
      task_process_queue = DockerOperator(task_id="process_task_{}".format(i), command="""python foo --queue-name={{ task_instance.xcom_pull(task_ids=scp_queue_task_{}) }}""".format(i), retries=3, dag=dag, pool="process_pool", api_version="auto", image="foo", queue="foo", execution_timeout=timedelta(minutes=5))
      task_manifest = DockerOperator(api_version="auto", task_id="manifest_task_{}".format(i), image="foo", retries=3, dag=dag, command=""" python --manifestid={{ task_instance.xcom_pull(task_ids=scp_queue_task_{}) }}""".format(i), pool="manfiest_pool", queue="d_parser")
  
      task_psql_queue.set_downstream(task_scp_queue)
      task_process_queue.set_upstream(task_scp_queue)
      task_manifest.set_upstream(task_process_queue)
  </code></pre>
  
  <p>As you can see I tried just using Python format string in the Jinja template to pass the i variable in it, however that doesn't work.</p>
  
  <p>I've also tried using "task.task_id", and creating a new string with just the task_id but that doesn't work either.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Now command looks like this </p>
  
  <pre><code>command="""python foo \ 
      --queue-name="{{ 
      task_instance.xcom_pull(task_ids='scp_queue_task_{}') }}" 
       """.format(i)
  </code></pre>
  
  <p>And my debug logs from Airflow look like </p>
  
  <pre><code>Using Master Queue: process_{ 
  task_instance.xcom_pull(task_ids='scp_queue_task_31') }
  </code></pre>
  
  <p>So the string value is being populated but it's not executing the xcom_pull.</p>