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:
pipelineName:
- variables:
#my variable definition here for VERSION.
- 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?
Also I wanted to check if I'll be able to add additional script commands to a predefined step.
Say I have a predefined step called "deploy-images". Now in my pipeline, will I be able to add bash script before or after I run that predefined step, so that all of this is in 1 single step.
steps:
- step: &deploy-images
script: #few bash statements here
pipelines:
branches:
develop:
- step:
script: git checkout tags/$VERSION
*deploy-images
script: git describe --tags
Thanks in advance.