Maven release: next development version in batch mode

后端 未结 7 2360
一生所求
一生所求 2021-02-19 23:13

I have configured a Jenkins job to release my maven project automatically. This is done by using the following: mvn --batch-mode clean release:prepare release:perform

7条回答
  •  失恋的感觉
    2021-02-19 23:35

    You can use a custom groovy script to automatically provide maven-release-plugin with the releaseVersion and developmentVersion. Then the maven command would look somwthing like:

    mvn clean release:clean release:prepare release:perform -DreleaseVersion=${releaseVersion} -DdevelopmentVersion=${developmentVersion}

    Follow the steps in this answer and change the part of the groovy script to suite your use-cases (for example this part):

    def newFixVersion = 0;
    if (hasSnapshotPart) {  
        newMinorRelVersion = minorVersion;  
        newMinorDevVersion = minorVersion + 1;  
    } else {  
        //TODO: either throw an exception here or change the newMinorRelVersion newMinorDevVersion appropriately to suite your use-cases: 
            //throw new IllegalArgumentException("The pom at location " + POM_LOCATION + " contains the version " + projectVersion + " which is not a snapshot version (missing " + SNAPSHOT_PART + "). This is a released version and nothing should happen to it!");  
    }  
    

提交回复
热议问题