Skip to content

Instantly share code, notes, and snippets.

@maoo
Last active April 17, 2025 09:25
Show Gist options
  • Save maoo/4c62c3ec6fbc8f6e42b0bb3d17152d5e to your computer and use it in GitHub Desktop.
Save maoo/4c62c3ec6fbc8f6e42b0bb3d17152d5e to your computer and use it in GitHub Desktop.
Bitbucket pipeline issue
branches:
main:
# Check image's CommitIDs against Dev
- step:
name: Wait for image deplomyments
script:
- sleep 360
- step:
name: Set Dev environment
script:
- echo ENV=dev > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
<<: *check-java-images
size: 2x
name: Check Java images commitID against dev env
- step:
<<: *check-ui-image
size: 2x
name: Check UI image commitID against dev env
- step:
name: Check completed on dev
<<: *check-completed
deployment: dev
# Check image's CommitIDs against QA
- step:
name: Set QA environment
script:
- echo ENV=qa > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
<<: *check-java-images
size: 2x
name: Check Java images commitID against QA env
- step:
<<: *check-ui-image
size: 2x
name: Check UI image commitID against QA env
- step:
name: Check completed on qa
<<: *check-completed
deployment: qa
# Check image's CommitIDs against preprod
- step:
name: Set preprod environment
script:
- echo ENV=preprod > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
<<: *check-java-images
size: 2x
name: Check Java images commitID against preprod env
- step:
<<: *check-ui-image
size: 2x
name: Check UI image commitID against preprod env
- step:
name: Check completed on preprod
<<: *check-completed
deployment: preprod
# Check dev health endpoints
- step:
name: Set Dev environment
script:
- echo ENV=dev >> $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
name: Test Dev
<<: *check-endpoints
deployment: dev
# Check QA health endpoints
- step:
name: Set QA environment
script:
- echo ENV=qa >> $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
name: Test QA
<<: *check-endpoints
deployment: qa
# Check preprod health endpoints
- step:
name: Set preprod environment
script:
- echo ENV=preprod >> $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
name: Test preprod
<<: *check-endpoints
deployment: preprod
---
definitions:
services:
docker:
memory: 7168
##########################
# Common steps defintiions
##########################
steps:
- step: &build-test-java-modules
size: 4x
image: maven:3.9.6
condition:
changesets:
includePaths:
- "hudhud-search-configuration-files/**"
- "hudhud-search-java*/**"
- "bitbucket-pipelines.yml"
- "scripts/*maven*"
- "src/docker/**"
- "pom.xml"
caches:
- maven
- docker
services:
- docker
script:
- echo "Maven Docker images versions is $VERSION"
- ./scripts/build-maven-modules.sh
- step: &check-java-images
condition:
changesets:
includePaths:
- "hudhud-search-configuration-files/**"
- "hudhud-search-java*/**"
- "bitbucket-pipelines.yml"
- "scripts/*maven*"
- "src/docker/**"
- "pom.xml"
caches:
- docker
services:
- docker
script:
- export images_and_paths="hudhud-search-java-autocomplete-api|text/search/autocomplete hudhud-search-java-image-search-api|images/search hudhud-search-java-text-search-api|text/search hudhud-search-java-rag-api|rag"
- export CHECK_COMMAND="images"
- ./scripts/check-environment.sh
- step: &build-test-ui-modules
size: 2x
image:
name: registry.gitlab.com/hawsp/sdl/search-ui-builder:latest
username: $DOCKER_HUB_USER
password: $DOCKER_HUB_PASSWORD
condition:
changesets:
includePaths:
- "hudhud-search-ui/**"
- "bitbucket-pipelines.yml"
- "scripts/*ui*"
- "src/docker/**"
caches:
- node
- docker
services:
- docker
script:
- echo "UI Docker image version is $VERSION"
- ./scripts/build-ui-module.sh
- step: &check-ui-image
condition:
changesets:
includePaths:
- "hudhud-search-ui/**"
- "bitbucket-pipelines.yml"
- "scripts/*ui*"
- "src/docker/**"
caches:
- docker
services:
- docker
script:
- export images_and_paths="hudhud-search-ui|/"
- export CHECK_COMMAND="images"
- ./scripts/check-environment.sh
- step: &run-e2e-tests
size: 4x
image:
name: registry.gitlab.com/hawsp/sdl/hudhud-search-java-e2e-base:latest
username: $DOCKER_HUB_USER
password: $DOCKER_HUB_PASSWORD
condition:
changesets:
includePaths:
- "hudhud-search-configuration-files/**"
- "hudhud-search-java*/**"
- "hudhud-search-ui/**"
- "bitbucket-pipelines.yml"
- "src/docker/docker-compose.yml"
- "scripts/**"
caches:
- maven
- docker
- node
services:
- docker
script:
- ./scripts/run-e2e-test.sh
- step: &image-builder
name: Build and Push the UI Image builder
size: 2x
image: node:22.13
caches:
- docker
services:
- docker
condition:
changesets:
includePaths:
- "hudhud-search-ui/Dockerfile.build"
script:
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWORD $DOCKER_HUB
- docker build -t registry.gitlab.com/hawsp/sdl/search-ui-builder:latest -f hudhud-search-ui/Dockerfile.build .
- docker push registry.gitlab.com/hawsp/sdl/search-ui-builder:latest
- step: &check-endpoints
size: 2x
condition:
changesets:
includePaths:
- "hudhud-search-*/**"
- "bitbucket-pipelines.yml"
- "src/docker/**"
- "scripts/**"
caches:
- docker
services:
- docker
script:
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASSWORD $DOCKER_HUB
- export CHECK_COMMAND="endpoints"
- ./scripts/check-environment.sh
- step: &check-completed
name: Check completed
script:
- echo "Check completed on env $ENV"
- step: &update-index
size: 2x
name: Update index (data and mappings)
image:
name: registry.gitlab.com/hawsp/sdl/hudhud-search-java-test-dataset-loader:1.0.0-SNAPSHOT
username: $DOCKER_HUB_USER
password: $DOCKER_HUB_PASSWORD
caches:
- docker
services:
- docker
script:
- ./scripts/update-index.sh
# TODO - still not used/needed
- step: &security-scan
size: 2x
name: Security Scan
script:
- pipe: atlassian/git-secrets-scan:0.5.1
clone:
lfs: true
pipelines:
################################
# Pull Requests - build and test
################################
pull-requests:
'**':
# Debugging bitbucket - this code actually works here, not sure if it does under the main branch pipeline
#
# - step:
# name: Set Dev environment
# script:
# - echo ENV=dev > $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - ENV
# - step:
# name: Check Dev environment
# script:
# - echo "checking $ENV environment"
# - step:
# name: Check completed on dev
# deployment: dev
# script:
# - echo "check on $ENV environment completed"
# - step:
# name: Set QA environment
# script:
# - echo ENV=qa > $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - ENV
# - step:
# name: Check QA environment
# script:
# - echo "checking $ENV environment"
# - step:
# name: Check completed on QA
# deployment: qa
# script:
# - echo "check on $ENV environment completed"
# - step:
# name: Set Preprod environment
# script:
# - echo ENV=preprod > $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - ENV
# - step:
# name: Check Preprod environment
# script:
# - echo "checking $ENV environment"
# - step:
# name: Check completed on preprod
# deployment: preprod
# script:
# - echo "check on $ENV environment completed"
# END Debugging bitbucket
- parallel:
- step:
<<: *build-test-java-modules
name: Pull Request - Build and Test Maven modules
- step:
<<: *build-test-ui-modules
name: Pull Request - Build and Test UI module
- step:
<<: *run-e2e-tests
name: Pull Request - E2E Test Suite
branches:
########################################
# Main branch - publishing Docker images
########################################
main:
- step:
name: "Set release version to 1.0.0-SNAPSHOT"
script:
- echo VERSION=1.0.0-SNAPSHOT >> $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
# scripts know they have to push the image too
- VERSION
# Build/push Java modules and UI, in parallel
- parallel:
- step:
<<: *image-builder
name: Build and Push the UI Image builder
- step:
<<: *build-test-java-modules
name: Build, Test and Push Maven modules on main branch
- step:
<<: *build-test-ui-modules
name: Build, Test and Push the UI module on main branch
# Check image's CommitIDs against Dev
- step:
name: Wait for image deplomyments
script:
- sleep 360
- step:
name: Set Dev environment
script:
- echo ENV=dev > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
<<: *check-java-images
size: 2x
name: Check Java images commitID against dev env
- step:
<<: *check-ui-image
size: 2x
name: Check UI image commitID against dev env
- step:
name: Check completed on dev
<<: *check-completed
deployment: dev
# Waiting for answer from https://community.atlassian.com/forums/Bitbucket-questions/Overriding-variables-via-BITBUCKET-PIPELINES-VARIABLES-PATH/qaq-p/2996752#M116859
#
# # Check image's CommitIDs against QA
# - step:
# name: Set QA environment
# script:
# - echo ENV=qa > $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - ENV
# - step:
# <<: *check-java-images
# size: 2x
# name: Check Java images commitID against QA env
# - step:
# <<: *check-ui-image
# size: 2x
# name: Check UI image commitID against QA env
# - step:
# name: Check completed on qa
# <<: *check-completed
# deployment: qa
# # Check image's CommitIDs against preprod
# - step:
# name: Set preprod environment
# script:
# - echo ENV=preprod > $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - ENV
# - step:
# <<: *check-java-images
# size: 2x
# name: Check Java images commitID against preprod env
# - step:
# <<: *check-ui-image
# size: 2x
# name: Check UI image commitID against preprod env
# - step:
# name: Check completed on preprod
# <<: *check-completed
# deployment: preprod
# Update index on Dev
- step:
name: Set Dev environment variables for index update
script:
- echo TARGET_ENV="dev" > $BITBUCKET_PIPELINES_VARIABLES_PATH
- echo OS_HOST="dev.hawsp.com" > $BITBUCKET_PIPELINES_VARIABLES_PATH
- echo OS_PORT="9200" > $BITBUCKET_PIPELINES_VARIABLES_PATH
- echo REINDEX="true" > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- TARGET_ENV
- OS_HOST
- OS_PORT
- REINDEX
- step:
<<: *update-index
name: Update index in dev
# TODO - enable when tested on dev
#
# # Update index on QA
# - step:
# name: Set QA environment variables for index update
# script:
# script:
# - echo TARGET_ENV="qa" > $BITBUCKET_PIPELINES_VARIABLES_PATH
# - echo OS_HOST="search-index.qa.hawsp.com" > $BITBUCKET_PIPELINES_VARIABLES_PATH
# - echo OS_PORT="443" > $BITBUCKET_PIPELINES_VARIABLES_PATH
# - echo REINDEX="true" > $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - TARGET_ENV
# - OS_HOST
# - OS_PORT
# - REINDEX
# - step:
# <<: *update-index
# name: Update index in QA
# # Update index on preprod
# - step:
# name: Set preprod environment variables for index update
# script:
# - echo TARGET_ENV="preprod" > $BITBUCKET_PIPELINES_VARIABLES_PATH
# - echo OS_HOST="search-index.preprod.hawsp.com" > $BITBUCKET_PIPELINES_VARIABLES_PATH
# - echo OS_PORT="443" > $BITBUCKET_PIPELINES_VARIABLES_PATH
# - echo REINDEX="true" > $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - TARGET_ENV
# - OS_HOST
# - OS_PORT
# - REINDEX
# - step:
# <<: *update-index
# name: Update index in preprod
# # Check dev health endpoints
# - step:
# name: Set Dev environment
# script:
# - echo ENV=dev >> $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - ENV
# - step:
# name: Test Dev
# <<: *check-endpoints
# deployment: dev
# # Check QA health endpoints
# - step:
# name: Set QA environment
# script:
# - echo ENV=qa >> $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - ENV
# - step:
# name: Test QA
# <<: *check-endpoints
# deployment: qa
# # Check preprod health endpoints
# - step:
# name: Set preprod environment
# script:
# - echo ENV=preprod >> $BITBUCKET_PIPELINES_VARIABLES_PATH
# output-variables:
# - ENV
# - step:
# name: Test preprod
# <<: *check-endpoints
# deployment: preprod
########################################
# Custom - manually triggered via web UI
########################################
custom:
push-all-images:
- step:
name: "Set release version to 1.0.0-SNAPSHOT-$BITBUCKET_BRANCH"
script:
- echo VERSION=1.0.0-$BITBUCKET_BRANCH >> $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
# scripts know they have to push the image too
- VERSION
- parallel:
- step:
<<: *build-test-java-modules
name: Build, Test and Push Maven modules on branch $BITBUCKET_BRANCH
- step:
<<: *build-test-ui-modules
name: Build, Test and Push the UI module on branch $BITBUCKET_BRANCH
pipelines:
pull-requests:
'**':
- step:
name: Set Dev environment
script:
- echo ENV=dev > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
name: Check Dev environment
script:
- echo "checking $ENV environment"
- step:
name: Check completed on dev
deployment: dev
script:
- echo "check on $ENV environment completed"
- step:
name: Set QA environment
script:
- echo ENV=qa > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
name: Check QA environment
script:
- echo "checking $ENV environment"
- step:
name: Check completed on QA
deployment: qa
script:
- echo "check on $ENV environment completed"
- step:
name: Set Preprod environment
script:
- echo ENV=preprod > $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- step:
name: Check Preprod environment
script:
- echo "checking $ENV environment"
- step:
name: Check completed on preprod
deployment: preprod
script:
- echo "check on $ENV environment completed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment