Code Snippet

Just another Code Snippet site

[Maven] Send mail with attachment

<plugin>
	<artifactId>maven-antrun-plugin</artifactId>
	<version>1.7</version>
	<executions>
		<execution>
			<id>mail</id>
			<phase>deploy</phase>
			<goals>
				<goal>run</goal>
			</goals>
			<configuration>
				<!-- Send APK by mail -->
				<target name="sendMail">
					<mail 
						mailhost="${mail.host}" 
						mailport="${mail.port}" 
						user="${mail.user}"
						ssl="${mail.ssl}" 
						password="${mail.password}" 
						subject="[RELEASE] ${project.name} ${project.officialVersion}.${BUILD_NUMBER}">
						<from address="jenkins@eryos.fr"/>
						<replyto address="jenkins@eryos.fr"/>
						<to address="recipient@gmail.com"/>
						<message>Project : ${project.name} Version : ${project.officialVersion} Build Number : ${BUILD_NUMBER} Build Date : ${BUILD_ID}</message>
						<attachments>
							<fileset dir="${project.build.directory}">
								<include name="${project.artifactId}-${project.version}.jar"/>
							</fileset>
						</attachments>
					</mail>
				</target>
			</configuration>
		</execution>
	</executions>
	<dependencies>
		<dependency>
			<groupId>org.apache.ant</groupId>
			<artifactId>ant</artifactId>
			<version>1.8.3</version>
		</dependency>                                                               
		<dependency>
			<groupId>org.apache.ant</groupId>
			<artifactId>ant-javamail</artifactId>
			<version>1.8.3</version>
		</dependency>
		<dependency>
			<groupId>javax.mail</groupId>
			<artifactId>mail</artifactId>
			<version>1.4.5</version>
		</dependency>
	</dependencies>
</plugin>

, , ,


Comments are currently closed.