admin管理员组

文章数量:1123158

I'm trying to create a custom bitbucket pipeline which has 2 inputs - version and target environment that deploys a specific version of the app(based on git tags) to different environments.

image: python:3.12

clone:
  enabled: true
  depth: full
  lfs: false
definitions:
  caches:
    sonar: ~/.sonar/cache

pipelines:
  custom:
    ReleaseToEnvironment:
      - variables:
          - name: VERSION
            description: Enter version to deploy like v1.0.0
          - name: TARGET_ENV
            description: Image will be tagged with this value.
            default: qa
            allowed-values:
              - qa
              - preview

      - step:
          name: Checkout version
          script:
            - git describe --tags   #outputs the most recent tag - v1.2.0
            - echo "Deploying version ${VERSION} to $Environment environment..."
            - git checkout tags/$VERSION    
            - git describe --tags            #outputs the tag I want - v1.0.0
      - step:
          script:
            - git describe --tags      #again back to most recent tag v1.2.0

But the problem is if I checkout tag (say v1.0.0) in step 1, it's back to the most recent tags in all the subsequent steps. Like I never did the checkout. How can I stash or persist the git checkout in 1 step so that it stays there in the following step?

Thanks in advance.

本文标签: Issue with Persisting Git Checkout State Across Multiple Steps in Bitbucket PipelinesStack Overflow