# Bitbucket Pipelines with Maven: Complete Guide

**CloudRepo Team** Updated December 3, 2026 10 min read

Serving developers since 2016 Founder-run, no venture capital MFA, SSO and audit log on every plan

**Every feature on every plan, with unlimited users.** 14 days free. No credit card required.

[Start free trial](https://www.cloudrepo.io/signup)

Starting at $99/month billed annually.

This guide shows how to set up continuous integration with Bitbucket Pipelines and private Maven repositories so you can automatically build, test, and deploy your Java artifacts. If you’re new to Maven, our [guide to what Maven repositories are](https://www.cloudrepo.io/articles/what-is-a-maven-repository) covers the fundamentals, including repository types and configuration.

## Prerequisites

You’ll need:

- Apache Maven installed
- A Bitbucket repository with Pipelines enabled
- A CloudRepo account with a private Maven repository
- Basic understanding of [Maven repositories](https://www.cloudrepo.io/articles/what-is-a-maven-repository) and Git

CloudRepo, JFrog Artifactory and Sonatype Nexus, side by side

Compare CloudRepo with

JFrog Nexus

| Question            | CloudRepo Essentials                     | JFrog Artifactory Cloud Pro                                                                                                    | Sonatype Nexus Pro Cloud                                                                                                |
| ------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| Entry price         | $99/month billed annually, $1,188 a year | $150/month list price, billed monthly [\[1\]](#vc--src-pages-articles-slug-astro-src-1)                                        | $1,950/year plus consumption [\[2\]](#vc--src-pages-articles-slug-astro-src-2)                                          |
| Included each month | 10 GB storage and 250 GB transfer        | 25 GB, then $1.25/GB storage and transfer counted together [\[1\]](#vc--src-pages-articles-slug-astro-src-1)                   | 25 GB, then $1.10/GB of consumption [\[2\]](#vc--src-pages-articles-slug-astro-src-2)                                   |
| Users               | Unlimited, on every plan                 | Typically up to 50 users how JFrog sizes Pro [\[1\]](#vc--src-pages-articles-slug-astro-src-1)                                 | New contracts are priced by consumption [\[3\]](#vc--src-pages-articles-slug-astro-src-3)                               |
| Support             | Human support, on every plan             | Community support: public documentation, a knowledge base and Stack Overflow [\[4\]](#vc--src-pages-articles-slug-astro-src-4) | Pro lists enterprise support, SLA and migration services as available [\[2\]](#vc--src-pages-articles-slug-astro-src-2) |
| Single sign-on      | Included on all plans                    | Not in Pro: JFrog lists SAML and OAuth sign-on for Enterprise X [\[4\]](#vc--src-pages-articles-slug-astro-src-4)              | SAML single sign-on on Pro [\[5\]](#vc--src-pages-articles-slug-astro-src-5)                                            |

Every feature on every plan

[Start free trial](https://www.cloudrepo.io/signup) [Or compare your Sonatype or JFrog quote with ours](https://www.cloudrepo.io/contact?quote=renewal)

14 days free. No credit card required.

Starting at $99/month billed annually.

Sources (5): each vendor's own pages, read 2026-10-06 to 2026-10-21. Prices as each vendor listed them on the date shown.

1. [JFrog pricing](https://jfrog.com/pricing/), read 2026-10-06 ([archived](https://web.archive.org/web/20261006092452/https://jfrog.com/pricing/))
2. [Sonatype pricing](https://www.sonatype.com/products/pricing), read 2026-10-06 ([archived](https://web.archive.org/web/20261006095617/https://www.sonatype.com/products/pricing))
3. [Sonatype pricing](https://www.sonatype.com/products/pricing), read 2026-10-21
4. [JFrog pricing](https://jfrog.com/pricing/), read 2026-10-07 ([archived](https://web.archive.org/web/20261007021220/https://jfrog.com/pricing/)) "Community Support - Available for Free solutions and Pro subscriptions - JFrog maintains public documentation, knowledge base, and engages in conversations on Stack Overflow.""Enterprise X is for organizations who need multi-site capabilities, uptime and support guarantees, and enterprise access controls (ie. OAuth, SAML, CName)."
5. [Nexus Repository feature matrix](https://help.sonatype.com/en/nexus-repository-feature-matrix.html), read 2026-10-06

## Setting Up Your Environment

### 1. Enable Bitbucket Pipelines

Go to your Bitbucket repository settings and enable Pipelines. This lets you run automated builds on every push to your repository.

### 2. Configure Secure Environment Variables

In your Bitbucket repository settings, add these secure environment variables:

- `CLOUDREPO_USERNAME`: the email address of the CloudRepo member the token belongs to
- `CLOUDREPO_API_TOKEN`: a repository token, created in the admin portal under Repository Tokens

These variables will be used to authenticate with your private Maven repository without exposing credentials in your code. Revoking a repository token stops that one credential and leaves the rest of the member’s access alone.

## Configuration Files

### Create bitbucket-pipelines.yml

Add this file to your repository root:

```yaml
pipelines:
  branches:
    master:
      - step:
          name: Build and Deploy Snapshot Artifact
          script:
            - bash create-settings.sh
            - mvn -B verify
            - mvn -B --ignore-transitive-repositories -s settings.xml deploy


    release/*:
      - step:
          name: Build and Deploy Release Artifact
          script:
            - bash create-settings.sh
            - mvn -B verify
            - mvn -B --ignore-transitive-repositories -s settings.xml deploy
```

`--ignore-transitive-repositories` makes Maven ignore repositories that a dependency’s POM declares. A dependency that resolves only from a repository its POM names then needs that repository in your own `pom.xml`. The flag needs Maven `3.9.7` or later; on an older Maven, leave the flag out, because your `pom.xml` still declares your CloudRepo repository for that id.

### Configure Your POM File

Add the repositories and distribution management to your `pom.xml`, with the same `id`s as the servers in `settings.xml` below. Your `pom.xml` declares each one so Maven uses your CloudRepo entry for that id.

```xml
<repositories>
    <repository>
        <id>io.cloudrepo.maven.releases</id>
        <url>https://[your-domain].mycloudrepo.io/repositories/maven-releases</url>
    </repository>
    <repository>
        <id>io.cloudrepo.maven.snapshots</id>
        <url>https://[your-domain].mycloudrepo.io/repositories/maven-snapshots</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>io.cloudrepo.maven.releases</id>
        <url>https://[your-domain].mycloudrepo.io/repositories/maven-releases</url>
    </pluginRepository>
    <pluginRepository>
        <id>io.cloudrepo.maven.snapshots</id>
        <url>https://[your-domain].mycloudrepo.io/repositories/maven-snapshots</url>
    </pluginRepository>
</pluginRepositories>
<distributionManagement>
    <repository>
        <id>io.cloudrepo.maven.releases</id>
        <url>https://[your-domain].mycloudrepo.io/repositories/maven-releases</url>
    </repository>
    <snapshotRepository>
        <id>io.cloudrepo.maven.snapshots</id>
        <url>https://[your-domain].mycloudrepo.io/repositories/maven-snapshots</url>
    </snapshotRepository>
</distributionManagement>
```

### Create Settings Generator Script

Create `create-settings.sh` to write Maven’s settings file:

`create-settings.sh`

```bash
#!/bin/bash
cat > settings.xml << 'EOF'
<settings>
  <servers>
    <server>
      <id>io.cloudrepo.maven.releases</id>
      <username>${env.CLOUDREPO_USERNAME}</username>
      <password>${env.CLOUDREPO_API_TOKEN}</password>
    </server>
    <server>
      <id>io.cloudrepo.maven.snapshots</id>
      <username>${env.CLOUDREPO_USERNAME}</username>
      <password>${env.CLOUDREPO_API_TOKEN}</password>
    </server>
  </servers>
</settings>
EOF
```

The quotes around `'EOF'` keep the shell from filling in the values. Maven reads `${env.CLOUDREPO_USERNAME}` and `${env.CLOUDREPO_API_TOKEN}` from the pipeline’s variables when it runs, so the file holds no login.

## Deployment Workflow

### Snapshot Deployments

Every push to the master branch will:

1. Run tests using `mvn verify`
2. Deploy snapshot artifacts to your snapshot repository
3. Make artifacts available for other projects immediately

### Release Deployments

For release versions:

1. Create a release branch (e.g., `release/1.0.0`)
2. Update version in `pom.xml` to remove `-SNAPSHOT`
3. Push to trigger the release pipeline
4. Tag the release after successful deployment

## Validating Your Setup

### Check Pipeline Status

After pushing changes:

1. Go to Pipelines in your Bitbucket repository
2. Monitor the build progress
3. Check for any errors in the build logs

### Verify Artifacts in CloudRepo

1. Log into your CloudRepo account
2. Go to your repositories
3. Confirm artifacts appear in the correct repository (snapshots or releases)
4. Verify artifact metadata is correct

## Best Practices

### Security

- Never commit credentials to your repository
- Use environment variables for sensitive data
- Rotate credentials regularly
- Use repository-specific credentials when possible

### Version Management

- Use semantic versioning (MAJOR.MINOR.PATCH)
- Keep snapshot versions on master/develop branches
- Create release branches for stable releases
- Tag releases in Git after successful deployment

### Build Optimization

- Cache dependencies to speed up builds
- Run tests in parallel when possible
- Use `-B` flag for non-interactive builds
- Consider using build profiles for different environments

## Troubleshooting

### Common Issues

**Authentication Failures**

- Verify environment variables are set correctly
- Check credentials haven’t expired
- Ensure repository IDs match between POM and settings

**Network Issues**

- Verify repository URLs are correct
- Check firewall settings
- Ensure HTTPS is used for secure connections

**Build Failures**

- Review build logs for specific errors
- Run builds locally to reproduce issues
- Check for dependency conflicts

## Advanced Configuration

### Multi-Module Projects

For projects with multiple modules:

```xml
<modules>
    <module>core</module>
    <module>api</module>
    <module>web</module>
</modules>
```

Configure each module to inherit distribution management from the parent POM.

### Custom Deployment Profiles

Create profiles for different deployment scenarios:

```xml
<profiles>
    <profile>
        <id>staging</id>
        <distributionManagement>
            <!-- Staging repository configuration -->
        </distributionManagement>
    </profile>
</profiles>
```

## Conclusion

That’s it: every push builds and publishes to CloudRepo. Try it free for 14 days.

## Additional Resources

- [Example Repository](https://bitbucket.org/cloudrepo-examples/maven-library-example)
- [Maven Documentation](https://maven.apache.org/guides/)
- [Bitbucket Pipelines Documentation](https://support.atlassian.com/bitbucket-cloud/docs/get-started-with-bitbucket-pipelines/)
- [CloudRepo Documentation](https://www.cloudrepo.io/docs/index.html)

## Every feature on every plan, with unlimited users

[Start free trial](https://www.cloudrepo.io/signup) [Or compare your Sonatype or JFrog quote with ours](https://www.cloudrepo.io/contact?quote=renewal)

14 days free. No credit card required.

Starting at $99/month billed annually.

![Chris Shellenbarger, founder of CloudRepo](https://www.cloudrepo.io/_astro/chris-headshot-150.DWO5wLdz.jpg)

**Founder-run since 2016, with no venture capital.** A real person answers within one business day. Usually it's me.

Chris, founder of CloudRepo

[Book time with Chris](https://www.cloudrepo.io/meet)

## Related articles

- [How to Use CloudRepo with GitHub Actions 10 min](https://www.cloudrepo.io/articles/github-actions-cloudrepo-integration)
- [JFrog API keys: what JFrog's pages say, and re-keying once onto CloudRepo 6 min](https://www.cloudrepo.io/articles/jfrog-api-keys-re-key-once-onto-cloudrepo)
- [Migrate from Sonatype Nexus 3 to CloudRepo 5 min](https://www.cloudrepo.io/articles/migrate-from-nexus-to-cloudrepo)

---

The page: https://www.cloudrepo.io/articles/continuous-integration-bitbucket-pipelines-maven
