0
votes

I'm using bamboo and we've started using branches now but we're having issues around the version control.

I'd like branch builds to be separate from release builds when pushed to nexus as I build a branch and if someone builds master later there is a naming clash.

Can someone guide me in resolving this? Or I need to post some other code I can.

Thanks for help

my pom is


<artifactId>sys-service</artifactId>
    <version>1.0.18-SNAPSHOT</version>


<distributionManagement>
        <repository>
            <id>nexus</id>
            <name>Internal Releases</name>
            <url>https://nexus.com/repository/release/</url>
        </repository>
        <snapshotRepository>
            <id>nexus</id>
            <name>Nexus Snapshots</name>
            <url>https://nexus.com/repository/snapshot/</url>
        </snapshotRepository>
    </distributionManagement>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>mule-repo</name>
            <layout>default</layout>
            <url>https://nexus.com/repository/mule-repo/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

1

1 Answers

0
votes

My solution to a similar problem like this consists of 2 parts. We are using Gradle, but this could probably be adjusted for Maven as well.

First, in the Bamboo Tasks configuration I pass an additional branchName parameter to the Gradle build.

-PnexusUser=${bamboo.NEXUS_USER} -PnexusPassword=${bamboo.NEXUS_PASSWORD} -PbranchName=${bamboo.repository.git.branch}

Second, my Gradle build script uses the Bamboo passed branch name to determine whether to skip uploading anything being built from develop or master.

/*
 * We only want to allow Bamboo to upload JAR builds to Nexus from 'develop' or 'master'
 */
if (project.hasProperty('branchName')) {
    if (branchName != 'master' && branchName != 'develop') {
        upload = false
        print "*** Branch '${branchName}' not applicable for upload! Nexus upload skipped.\n";
    } else {
        print "*** Uploading branch '${branchName}' to Nexus ...\n"
    }
}

Perhaps you could use this idea to adjust your build process as well.