Commit 53565f6c authored by Selvakumar Kamatchinathan's avatar Selvakumar Kamatchinathan
Browse files

changes suggested by cyenyxe

parent 6ee9f66a
......@@ -15,6 +15,7 @@ pipeline {
fallbackHost = credentials('FALLBACKHOST')
productionHost = credentials('PRODUCTIONHOST')
smtpHost = credentials('SMTPHOST')
ampt2dEmaiId = credentials('AMPT2DEMAILID')
}
parameters {
booleanParam(name: 'DeployToStaging' , defaultValue: false , description: '')
......@@ -23,7 +24,7 @@ pipeline {
stages {
stage('Default Build pointing to Staging DB') {
steps {
sh "mvn clean package -DskipTests -DbuildDirectory=staging/target -Dampt2d-property-registry-db.url=${stagingPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost}"
sh "mvn clean package -DskipTests -DbuildDirectory=staging/target -Dampt2d-property-registry-db.url=${stagingPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost} -Damp-t2d-email-id=${ampt2dEmaiId}"
}
}
stage('Build For FallBack And Production') {
......@@ -34,9 +35,9 @@ pipeline {
}
steps {
echo 'Build pointing to FallBack DB'
sh "mvn clean package -DskipTests -DbuildDirectory=fallback/target -Dampt2d-property-registry-db.url=${fallBackPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost}"
sh "mvn clean package -DskipTests -DbuildDirectory=fallback/target -Dampt2d-property-registry-db.url=${fallBackPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost} -Damp-t2d-email-id=${ampt2dEmaiId}"
echo 'Build pointing to Production DB'
sh "mvn clean package -DskipTests -DbuildDirectory=production/target -Dampt2d-property-registry-db.url=${productionPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost}"
sh "mvn clean package -DskipTests -DbuildDirectory=production/target -Dampt2d-property-registry-db.url=${productionPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost} -Damp-t2d-email-id=${ampt2dEmaiId}"
}
}
stage('Deploy To Staging') {
......@@ -47,7 +48,7 @@ pipeline {
}
steps {
echo 'Deploying to Staging'
sh "curl --upload-file staging/target/amp-t2d-property-registry-*.war 'http://'${tomcatCredentials}'@'${stagingHost}':8080/manager/text/deploy?path=/dev/registry&update=true' | grep 'OK - Deployed application at context path '"
sh "curl --upload-file staging/target/amp-t2d-property-registry-*.war 'http://'${tomcatCredentials}'@'${stagingHost}':8080/manager/text/deploy?path=/registry&update=true' | grep 'OK - Deployed application at context path '"
}
}
stage('Deploy To FallBack And Production') {
......
......@@ -35,7 +35,7 @@ import javax.validation.constraints.Size;
import java.time.ZonedDateTime;
@Entity
@EntityListeners({AuditingEntityListener.class,EntityEventListener.class})
@EntityListeners({AuditingEntityListener.class, EntityEventListener.class})
public class Property implements IdentifiableEntity<String> {
public enum Type {
......
......@@ -17,6 +17,7 @@
*/
package uk.ac.ebi.ampt2d.registry.exceptionhandling;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.mail.MailSendException;
......@@ -32,12 +33,15 @@ public class ExceptionHandlers {
private static final Logger exceptionLogger = Logger.getLogger(ExceptionHandlers.class.getSimpleName());
@Value("${mail.from}")
private String mailFrom;
@ExceptionHandler(value = TransactionSystemException.class)
public ResponseEntity<String> handleMailSendException(TransactionSystemException ex) {
if (ex.getOriginalException().getCause().getClass().equals(MailSendException.class)) {
exceptionLogger.log(Level.SEVERE, ex.getOriginalException().getCause().getMessage());
return new ResponseEntity("Mail send exception, please contact amp-dev@ebi.ac.uk", HttpStatus
.INTERNAL_SERVER_ERROR);
return new ResponseEntity("An automated email could not be sent, please contact " + mailFrom,
HttpStatus.INTERNAL_SERVER_ERROR);
}
throw ex;
}
......
......@@ -27,9 +27,8 @@ spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.ssl.enable=false
mail.from=amp-dev@ebi.ac.uk
mail.to=amp-dev@ebi.ac.uk
mail.from=@amp-t2d-email-id@
mail.to=@amp-t2d-email-id@
mail.subject=AMP-T2D Registry Update
registry.protocols=https
\ No newline at end of file
......@@ -45,7 +45,7 @@ public class RegistryUpdateNotificationFailure {
String phenotypeContent = "{\"id\":\"BMI\"," + "\"phenotypeGroup\":\"ANTHROPOMETRIC\"}";
mockMvc.perform(post("/phenotypes").content(phenotypeContent))
.andExpect(status().isInternalServerError())
.andExpect(content().string("Mail send exception, please contact amp-dev@ebi.ac.uk"));
.andExpect(content().string("An automated email could not be sent, please contact user@domain"));
}
}
......@@ -18,8 +18,8 @@ spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.ssl.enable=false
mail.from=amp-dev@ebi.ac.uk
mail.to=selva@ebi.ac.uk
mail.from=user@domain
mail.to=user@domain
mail.subject=AMP-T2D Registry Update
security.enabled=false
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment