Skip to content

Instantly share code, notes, and snippets.

@AlexRogalskiy
Forked from 256BitChris/bitbucket-pipelines.yml
Created February 10, 2023 22:16
Show Gist options
  • Save AlexRogalskiy/1c9702bedd95a9b1d9e6b5cf9ba07c53 to your computer and use it in GitHub Desktop.
Save AlexRogalskiy/1c9702bedd95a9b1d9e6b5cf9ba07c53 to your computer and use it in GitHub Desktop.
Example BitBucket Pipeline YML file for Maven Projects
image: atlassian/default-image:2
pipelines:
branches:
master: # Trigger this for any pushes to the master branch.
- step:
name: Build and Deploy Snapshot Artifact
trigger: automatic
caches:
- maven # Cache any dependencies we download, speeds up build times.
script:
- bash create-settings.sh # Create our settings.xml file. Will fail if environment variables aren't set properly.
- mvn -B verify # Ensure all artifacts build successfully before we attempt deploy in order to prevent partial deploys.
- mvn -B -s settings.xml deploy # Now that all builds have completed, we can deploy all the artifacts.
- step:
name: Create Release Version # This will create a release version and commit it to master. It will then be picked up and deployed in the first step.
trigger: manual
caches:
- maven
script:
- bash create-settings.sh # Create our settings.xml file. Will fail if environment variables aren't set properly.
- bash validate-release-configuration.sh # Do the best we can to ensure we have the SSH keys and env variables in place before we try to prepare a release.
- git config --global user.email "$GIT_USER_EMAIL"
- git config --global user.name "$GIT_USER_NAME"
- mvn -B -DdryRun=true release:prepare # Ensure that most things will run properly before we do the real work.
- mvn -B release:clean release:prepare # This bumps the versions in the poms, creates new commits, which will then get built by the master branch trigger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment