Posts Jenkins ant script to create a maven branch and release project
Post
Cancel

Jenkins ant script to create a maven branch and release project

  • Call target from pom.xml
1
2
3
4
5
6
7
<configuration>
    <target>
        <ant antfile="${basedir}/build.xml">
            <target name="deploy" />
        </ant>
    </target>
</configuration>
  • Ant login to remote svn box and checkout source code
1
2
3
4
5
6
7
8
<sshexec 
        host="buildserver.domain.com"
        username="svnadmin" 
        password="svnadmin"
        command="cd /home/builduser/scripts/;
        . .bash_profile;
        svn co http://buildserver.domain.com:8080/svn/${repo_name}/trunk/${app_name}" 
        trust="true" />
  • Ant login to remote svn box and create release branch
1
2
3
4
5
6
7
8
9
<sshexec 
        host="buildserver.domain.com"
        username="svnadmin" 
        password="svnadmin"
        command="cd /home/builduser/scripts/;
        . .bash_profile;
        cd ${app_name};
        mvn -B release:branch -Dusername=svnadmin -Dpassword=adminpassword -DbranchName=${app_name}-${releaseversion}-branch -DreleaseVersion=${releaseversion}.0 -DautoVersionSubmodules=true -DupdateBranchVersions=true -DupdateWorkingCopyVersions=false -DremoteTagging=false -DsuppressCommitBeforeBranch=true" 
        trust="true" />
  • Ant login to remote svn box and delete release branch local folder
1
2
3
4
5
6
7
8
<sshexec 
    host="buildserver.domain.com"
    username="svnadmin" 
    password="svnadmin"
    command="cd /home/builduser/scripts/;
    . .bash_profile;
    rm -rf ${app_name}" 
    trust="true" />
  • Ant login to remote svn box and checkout release branch from svn
1
2
3
4
5
6
7
8
9

<sshexec 
    host="buildserver.domain.com"
    username="svnadmin" 
    password="svnadmin"
    command="cd /home/builduser/scripts/;
    . .bash_profile;
    svn co http://buildserver.domain.com:8080/svn/${repo_name}/branches/${app_name}-${releaseversion}-branch" 
    trust="true" />
  • Ant login to remote svn box, build and release project
1
2
3
4
5
6
7
8
9
10
11
12

<sshexec 
        host="buildserver.domain.com"
        username="svnadmin" 
        password="svnadmin"
        command="cd /home/builduser/scripts/;
        . .bash_profile;
        cd ${app_name}-${releaseversion}-branch;
        mvn versions:use-releases versions:commit;
        svn commit -m 'Replaced -SNAPSHOT versions with the corresponding release version.';
        mvn -e -B release:clean release:prepare release:perform -Dusername=svnadmin -Dpassword=adminpassword -Darguments='-Dmaven.test.skip=true' -DautoVersionSubmodules=true -DuseReleaseProfile=false -P live" 
        trust="true" />

Source

This post is licensed under CC BY 4.0 by the author.