If creating and configuring a git repository, use the git plugin. You can download the plugin here: http://plugins.urbancode.com/anthill3/plugin/Git. Once downloaded, upload it to Anthill (System > Server > Plugins). Use the git plugin rather than the git integration when creating and configuring repositories and workflows.
Edit ~/.m2/settings.xml to be something like:
To use mirrors:
<settings> <servers> <server> <id>anthill</id> <username>admin</username> <password>admin</password> </server> </servers> <mirrors> <mirror> <id>anthill</id> <name>Maven Repository Manager running on Anthill Pro Server at ${env.AH_WEB_URL}</name> <url>${env.AH_WEB_URL}/rest/maven2/${env.AH_BUILD_LIFE_ID}</url> <mirrorOf>*</mirrorOf> </mirror> </mirrors> </settings>
Make sure IDs match and Maven repositories are configured in AnthillPro as in step 2. All repositories will be mirrored to the AnthillPro server, but you can choose which repositories to mirror in the pom file by using [id], or ![id].
To use profiles:
<servers> <server> <id>ahp-repo</id> <username>admin</username> <password>admin</password> </server> <server> <id>ahp-dist</id> <username>PasswordIsAuthToken</username> <password>${env.AH_AUTH_TOKEN}</password> </server> </servers> <profiles> <profile> <id>default</id> <repositories> <repository> <id>central</id> <name>Maven Repository Switchboard</name> <url>http://repo1.maven.org/maven2</url> </repository> </repositories> </profile> <profile> <id>ahp-dev</id> <repositories> <repository> <id>ahp-repo</id> <name>AHP Maven Repository Mirror</name> <url>${env.AH_WEB_URL}/rest/maven2</url> </repository> </repositories> </profile> <profile> <id>ahp-dist</id> <repositories> <repository> <id>ahp-dist</id> <name>AHP Maven Repository Mirror</name> <url>${env.AH_WEB_URL}/rest/maven2dist/${env.AH_BUILD_LIFE_ID}</url> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>ahp-dist</activeProfile> </activeProfiles>
Ensure IDs match and any Maven repositories are configured in as in step 2
# Create a single project in AnthillPro.
When configuring the Maven builder, use deploy for the goal and -U, and -P<profileId> (if you are using profiles and not mirrors; only necessary if you do not specify ahp-dist as the active profile in settings.xml), and -DaltDeploymentRepository=<serverId>::default::${env.AH_WEB_URL}/rest/maven2dist/${env.AH_BUILD_LIFE_ID} for the âMaven Propertiesâ
Note: Arguments/flags are called Maven Properties in AnthillPro.
import com.urbancode.anthill3.domain.singleton.serversettings.*; import com.urbancode.anthill3.domain.buildlife.*; import com.urbancode.anthill3.domain.jobtrace.*; import com.urbancode.anthill3.domain.jobtrace.buildlife.*; import com.urbancode.anthill3.runtime.scripting.helpers.*; import com.urbancode.commons.xml.DOMUtils; private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("ContextScript"); // BUILD_STEP_NAME: Name of the step within the job that should be inspected String BUILD_STEP_NAME = "Echo POM"; BuildLifeJobTrace jobTrace = JobTraceLookup.getCurrent(); StepTrace[] stepTraceArray = jobTrace.getStepTraceArray(); StepTrace stepTrace = null; for (int j = 0; j < stepTraceArray.length && stepTrace == null; j++) { if (stepTraceArray[j].getName().equalsIgnoreCase(BUILD_STEP_NAME)) { stepTrace = stepTraceArray[j]; break; } } String outputLog = LogHelper.getOutput(stepTrace.getCommandTraceArray()[0]); // The output log contains junk other than the pom. Trim that out. String docStartFlag = "<project"; String docEndFlag = "command exit"; startIndex = outputLog.indexOf(docStartFlag); endIndex = outputLog.indexOf(docEndFlag); outputLog = outputLog.substring(startIndex, endIndex); // Load the POM as an XML doc and get the version value doc = DOMUtils.loadDocument(outputLog); topElement = doc.getDocumentElement(); version = DOMUtils.getFirstChildText(topElement, "version"); stampContext.put("version", ""+version);
import com.urbancode.anthill3.domain.singleton.serversettings.*; import com.urbancode.anthill3.domain.buildlife.*; import com.urbancode.anthill3.domain.jobtrace.*; import com.urbancode.anthill3.domain.jobtrace.buildlife.*; import com.urbancode.anthill3.runtime.scripting.helpers.*; import com.urbancode.commons.xml.DOMUtils; import com.urbancode.vcsdriver3.*; private org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("ContextScript"); // BUILD_STEP_NAME: Name of the step within the job that should be inspected String BUILD_STEP_NAME = "Echo POM"; // String COMMAND_NAME = "shell-command"; BuildLifeJobTrace jobTrace = JobTraceLookup.getCurrent(); StepTrace[] stepTraceArray = jobTrace.getStepTraceArray(); StepTrace stepTrace = null; for (int j = 0; j < stepTraceArray.length && stepTrace == null; j++) { if (stepTraceArray[j].getName().equalsIgnoreCase(BUILD_STEP_NAME)) { stepTrace = stepTraceArray[j]; break; } } String outputLog = LogHelper.getOutput(stepTrace.getCommandTraceArray()[0]); // The output log contains junk other than the pom. Trim that out. String docStartFlag = "<project"; String docEndFlag = "command exit"; startIndex = outputLog.indexOf(docStartFlag); endIndex = outputLog.indexOf(docEndFlag); outputLog = outputLog.substring(startIndex, endIndex); // Load the POM as an XML doc and get the version value doc = DOMUtils.loadDocument(outputLog); topElement = doc.getDocumentElement(); version = DOMUtils.getFirstChildText(topElement, "version"); // Great, now let's dig out the SVN or Perforce changeset int getMaxChangeSet(BuildLife life) { int result = 0; ChangeLog[] changelogArray = ChangeLogHelper.getChangeLogArray(life); for (int i = 0; i < changelogArray.length; i++) { ChangeSet[] changesetArray = changelogArray[i].getChangeSetArray(); for (int j = 0; j < changesetArray.length; j++) { ChangeSet changeset = changesetArray[j]; id = changeset.getId(); // edit out the "r" character for svn if (id.startsWith("r")) { id = id.substring(1); } int num = (new Integer(id.trim())).intValue(); if (num > result) { result = num; } } } return result; } // If there is no changelog, look up the previous build // and take the highest number from that (if present, else keep searching). int highestChangeset = 0; BuildLife life = BuildLifeLookup.getCurrent(); while(highestChangeset == 0 && life != null) { highestChangeset = getMaxChangeSet(life); life = life.getPrevBuildLife(); } stampContext.put("version", ""+version); stampContext.put("changeset", ""+highestChangeset);