30
Using the ALM Module Fully Automated Deployments in Stack 3.2

Using the ALM Module Fully Automated Deployments in Stack 3.2

Embed Size (px)

Citation preview

Using the ALM ModuleFully Automated Deployments in Stack 3.2

Disclaimer

• This is a training NOT a presentation.– Be prepared to learn and participate in lab

• Please ask questions• Prerequisites:– Maven Knowledge• https://tech.lds.org/wiki/Java_Stack_Training

Build and Deployment History in ICS

• In the beginning Maven and CruiseControl– Produced an .ear

• Automated config and deploy Bundles– Produced a .zip with an .ear/.war and env config– DB Migrator produced a migration .zip

• Anthill Pro replaces CruiseControl– Introduced secondary process execution

Typical Deploy Process Today

Deployment to Stage/ProdASE downloads deploy .zip and deploys to

stage/prod. DBE Updates Stage/prod DB. QA manually validates app.

Deployment to Test LanesQA initiates deploy from Anthill Secondary

Process. DBE updates the Test DBs. QA executes functional tests.

Build ProcessAnthill initiates automated Maven build

and test. Maven Build deploys to dev. Maven Build migrates dev DB.

Development ProcessDeveloper develops code. Tests on local box with shared

DB. Writes and runs unit tests. No functional tests run.

Problems with Deploy Process

• Application Deploy only thing automated• Difficult to introduce other automations• Deployments initiated 3 different ways• Project build complex– Mixture of artifact build and deploy

• Build fails if dev deploy fails (no artifact produced)• Changes to deploy process managed by build

team• Testing automated in build but not in promotions

Goals of Deploy Improvements

• Support automating most any deploy task• Give team more power to customize deploy

automation• Simplify build: separate build and deploy– Once per build vs. Many per build

• Make deploy execution consistent (all lanes)• Leverage current investment in Maven• First class Anthill Pro Support• Flexible enough to execute outside of Anthill Pro

Non-Goals for Deploy Improvements

• Provisioning (created vs. updated)• Any asynchronous processes (e.g. Approvals)

Introducing the ALM Module

• What is the ALM Module?– Maven module packages itself up– Can be executed later– Includes its own dependencies– Contains all build promotion logic

Possible Deploy Task Use Cases

• Execute DB migration with build• Execute functional/acceptance tests• Deploy static resources separate from application• Expire cache/CDN on deploy• Push internationalization resources to DB• Update WAM policies (when Exposee is ready)• Deploy several applications at one time• Push shared library to Nexus only when app is

promoted.

ALM Module Demo

Maven Lifecycles

• Maven uses lifecycles to orchestrate goals• Phases represent steps in a lifecycle

Default

process-resources

compile

test-compile

test

package

integration-test

install

deploy

Clean

pre-clean

clean

Site

site

site-deploy

Executing a Lifecycle

• Lifecycles are executed by calling a phase• Phase identifies where in lifecycle to stop• Examples:– mvn test– mvn install– mvn clean install– mvn site-deploy clean– mvn clean compile package install clean

Default

process-resources

compile

test-compile

test

package

integration-test

install

deploy

Clean

pre-clean

clean

Site

site

site-deploy

Phases in Lifecycle

• Phases in a lifecycle are mapped to plugin goals– Dictated by default, packaging type, and pom config

Default

Phases War

process-resources

compile compiler:compile

test-compile compiler:testCompile

test surefire:test

package war:war

integration-test

install install:install

deploy deploy:deploy

Clean

Phases Default

pre-clean

clean clean:clean

Site

Phases Default

site site:site

site-deploy site:deploy

Example Binding in Pom Config

<project> … <packaging>war</packaging> <build> <plugins>

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>1.0.1</version> <executions> <execution> <goals><goal>enforce</goal></goals> <phase>compile</phase> </execution> </executions> </plugin> </plugins> </build></project>

ALM the Lifecycle for Deployments

• Default Lifecycle builds and managing artifacts

• What might a lifecycle for application deployment look like?– Migrate database– Deploy app– Test deployed app

ALM Lifecycle

Phases alm-bundle Bindings

alm-db stack-db:migrate

alm-deploy stack-tcat:deploy

alm-test stack-test:functional-test

alm-promote

• Quiz:– clean install– alm-promote– clean install alm-promote

Packaging the ALM Module

• ALM Module creates a .zip containing:– The project– All Dependencies– settings.xml file

• Zip can be rerun• Same artifacts

ALM Execution Configuration

• Maven profiles represent environments• Profiles allow custom environment configuration– Choose deploy type/server– Execute different tests

• Maven properties provide configuration– Deploy Username/Password– Skip test run– Skip DB migration– Defaults in profile->properties– Can be customized on command line “-Dsome=value”

How to execute a post build promotion?

1. Download alm zip file for project2. Execute: mvn -s settings.xml alm-promote3. Optionally add appropriate ‘-D’ parameters4. Specify env using a maven profile (e.g. -P stage)

Lab 1

https://tech.lds.org/wiki/Using_the_ALM_Module#Lab_1

Customizing ALM Execution

How to Customize ALM Promotion

• Maven Plugins (Preferred)– Simplify common complex processes– Cross Platform

• Java Platform Scripts (OK)– Ant, Groovy, BeanShell, Java, etc.– Fully customizable– Cross Platform

• Shell Scripts (Worst Case)– Executed using maven-exec-plugin– Not Cross Platform

Maven Plugin Options

• Stack Tomcat Plugin– Local and SSH Tomcat deploys

• Stack Tcat Plugin• Stack DB Migrator Plugin• Stack Test Runner• Stack Was Deploy Plugin• Maven Deploy• Maven Wagon• Maven SCM Plugin

Java Platform Scripts

• Write custom scripts executed in Java– Cross Platform– More difficult to maintain– Common scripts will be candidates for plugins

• Maven Ant and Antrun Plugins– Very simple to execute ant scripts

• Gmaven Plugin• Maven Exec Plugin

Shell Scripts

• Custom shell scripts packaged with alm bundle– Executed with maven-exec-plugin– Can come in handy– Not cross platform

Lab 2

https://tech.lds.org/wiki/Using_the_ALM_Module#Lab_2

Executing ALM Promotion in Anthill Pro

Executing through Anthill Pro

• Anthill represents an excellent engine for executing ALM Modules– Securely store build artifacts– Can securely handle passwords– Easily add parameters to a maven build– Can track state of builds– Can record and store results from multiple test runs

Roles of new Build System

Project Team (Developers)• Developer ALM pom.xml for

project– Functional Tests?– DB Migration?– Test Groups? (smoke, full, etc)

• Identify the Environments to enable

• Test on local box• Identify Anthill configurable

properties– Skip Plugins?– Usernames and passwords?

Build Team• Add Project to Anthill• Take configurable properties

from team add them to UI.• Enable specified

environments

Java Stack Team• Help developer ALM

Module

Demo ALM Module and Anthill Pro

Conclusion

• ALM Module provides promotion orchestration• Puts more control in hands of project team• Build process now separate from promotion• Anthill pro is an excellent promotion engine

• We hope to see more automated promotions in the future!!!