title: How to pass parameter to Bitbucket pipeline pipe included in a step definition?
body: <p>I have the following Bitbucket pipeline</p>
  <pre><code># This image is used in both &quot;Zip and Upload to S3 steps&quot;
  image: atlassian/default-image:3
  
  pipelines:
    default:
      - step:
          script:
            # Include this step so that we can get a successful build when any
            # commit is made to a branch. This will allow us to merge to the
            # staging branch which requires a successful commit previously
            - echo &quot;The current branch is $BITBUCKET_BRANCH&quot;
  
    branches:
      staging:
        - step:
            # We have decided to include the Zip and upload to S3 sections of the
            # pipeline in the same step because of a bug in the pipeline within
            # artifacts. See https://jira.atlassian.com/browse/BCLOUD-21666 for
            # details.
            name: Zip &amp; Upload to S3
            services:
              - docker
            oidc: true
            script:
              # Build the zip file containing the contents of the applications
              # folder
              - zip -r $BITBUCKET_REPO_SLUG.zip &quot;applications&quot;
              # Upload the zip file to S3
              - pipe: atlassian/aws-code-deploy:1.1.1
                variables:
                  AWS_DEFAULT_REGION: $AWS_REGION
                  AWS_OIDC_ROLE_ARN: $AWS_OIDC_ROLE_ARN
                  COMMAND: &quot;upload&quot;
                  APPLICATION_NAME: $APPLICATION_NAME
                  ZIP_FILE: $BITBUCKET_REPO_SLUG.zip
                  S3_BUCKET: $S3_BUCKET_STAGING
                  VERSION_LABEL: $BITBUCKET_REPO_SLUG
  
        - step:
            name: Deploy code
            deployment: staging
            oidc: true
            script:
              - pipe: atlassian/aws-code-deploy:1.1.1
                variables:
                  AWS_DEFAULT_REGION: $AWS_REGION
                  AWS_OIDC_ROLE_ARN: $AWS_OIDC_ROLE_ARN
                  APPLICATION_NAME: $APPLICATION_NAME
                  COMMAND: &quot;deploy&quot;
                  DEPLOYMENT_GROUP: $DEPLOYMENT_GROUP_STAGING
                  S3_BUCKET: $S3_BUCKET_STAGING
                  WAIT: &quot;true&quot;
                  FILE_EXISTS_BEHAVIOR: OVERWRITE
                  VERSION_LABEL: $BITBUCKET_REPO_SLUG
  
      production:
        - step:
            # We have decided to include the Zip and upload to S3 sections of the
            # pipeline in the same step because of a bug in the pipeline within
            # artifacts. See https://jira.atlassian.com/browse/BCLOUD-21666 for
            # details.
            name: Zip &amp; Upload to S3
            services:
              - docker
            oidc: true
            script:
              # Build the zip file
              - zip -r $BITBUCKET_REPO_SLUG.zip &quot;applications&quot;
              # Upload the zip file to S3
              - pipe: atlassian/aws-code-deploy:1.1.1
                variables:
                  AWS_DEFAULT_REGION: $AWS_REGION
                  AWS_OIDC_ROLE_ARN: $AWS_OIDC_ROLE_ARN
                  COMMAND: &quot;upload&quot;
                  APPLICATION_NAME: $APPLICATION_NAME
                  ZIP_FILE: $BITBUCKET_REPO_SLUG.zip
                  S3_BUCKET: $S3_BUCKET_PROD
                  VERSION_LABEL: $BITBUCKET_REPO_SLUG
  
        - step:
            name: Deploy code
            deployment: production
            oidc: true
            script:
              - pipe: atlassian/aws-code-deploy:1.1.1
                variables:
                  AWS_DEFAULT_REGION: $AWS_REGION
                  AWS_OIDC_ROLE_ARN: $AWS_OIDC_ROLE_ARN
                  APPLICATION_NAME: $APPLICATION_NAME
                  COMMAND: &quot;deploy&quot;
                  DEPLOYMENT_GROUP: $DEPLOYMENT_GROUP_PROD
                  S3_BUCKET: $S3_BUCKET_PROD
                  WAIT: &quot;true&quot;
                  FILE_EXISTS_BEHAVIOR: OVERWRITE
                  VERSION_LABEL: $BITBUCKET_REPO_SLUG
  </code></pre>
  <p>As you can see, the staging and production branches are almost identical. The only differences are:</p>
  <ol>
  <li>The use of &quot;staging&quot; or &quot;production&quot; in the &quot;deployment&quot; variable</li>
  <li>The S3_BUCKET variable that is different depending on whether we are deploying to staging or production.</li>
  </ol>
  <p>To avoid duplicate code, I want to create a step definition that I can reuse. So for example, the definition for the &quot;Zip and Upload to S3&quot; step would look something like below</p>
  <pre><code>definitions:
    steps:
      - step: &amp;EchoCurrentBranch
          name: Echo current branch
          script:
            - echo &quot;The current branch is $BITBUCKET_BRANCH&quot;
  
      - step: &amp;ZipAndUploadToS3
          name: ⬆️ Zip &amp; Upload to S3
          services:
            - docker
          oidc: true
          script:
            # Build the zip file containing the contents of the applications
            # folder
            - zip -r $BITBUCKET_REPO_SLUG.zip &quot;applications&quot;
            # Upload the zip file to S3
            - pipe: atlassian/aws-code-deploy:1.1.1
              variables:
                AWS_DEFAULT_REGION: $AWS_REGION
                AWS_OIDC_ROLE_ARN: $AWS_OIDC_ROLE_ARN
                COMMAND: &quot;upload&quot;
                APPLICATION_NAME: $APPLICATION_NAME
                ZIP_FILE: $BITBUCKET_REPO_SLUG.zip
                S3_BUCKET: &lt;I want this variable to be changeable&gt;
                VERSION_LABEL: $BITBUCKET_REPO_SLUG
  </code></pre>
  <p>But the problem is that I can't find a way to pass a different value for the S3 bucket into the pipeline for different calls to the defined step. How do I pass in a different value for the S3 bucket into the pipe depending on the branch that I am deploying to?</p>
  <p>I know that it is possible to pass different values into step definitions (as shown in <a href="https://gist.github.com/prabhu/06245e0f5ce949aa8a93e448fbd6516c" rel="nofollow noreferrer">Reusable Bitbucket pipelines configuration with YAML anchors</a> for example) but I can't find anywhere that shows how to pass a pipe variable into a defined step.</p>