Skip to content

Commit

Permalink
amp-30916 migrate amp build process to new jenkins (#4365)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianbrix authored Jan 20, 2025
1 parent d1aa005 commit d25b07e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "amp/TEMPLATE/ampTemplate/node_modules/amp-boilerplate"]
path = amp/TEMPLATE/ampTemplate/node_modules/amp-boilerplate
url = https://github.com/devgateway/amp-boilerplate.git
url = git@github.com:devgateway/amp-boilerplate.git
[submodule "amp/TEMPLATE/ampTemplate/node_modules/amp-translate"]
path = amp/TEMPLATE/ampTemplate/node_modules/amp-translate
url = https://github.com/devgateway/amp-translate.git
url = git@github.com:devgateway/amp-translate.git
[submodule "amp/TEMPLATE/ampTemplate/node_modules/amp-filter"]
path = amp/TEMPLATE/ampTemplate/node_modules/amp-filter
url = https://github.com/devgateway/amp-filter.git
url = git@github.com:devgateway/amp-filter.git
29 changes: 15 additions & 14 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def updateGitHubCommitStatus(context, message, state) {
]
])
}

def codeVersion
def countries
def environment
Expand All @@ -62,15 +61,21 @@ stage('Build') {

println "Using environment: ${environment}"

node {
node('ansible') {
checkout scm


// Find AMP version
codeVersion = readMavenPom(file: 'amp/pom.xml').version
println "AMP Version: ${codeVersion}"

//Used in the initial generation of keys when working with a new jenkins instance
//****************************************************************
// sh "ssh-keygen -t rsa -b 4096 -C 'jenkins@${environment}' -f ~/.ssh/id_rsa -N ''"
sh "ssh-keyscan -H ${environment} >> ~/.ssh/known_hosts"
// sh "cat /root/.ssh/id_rsa.pub"
//******************************************************
countries = sh(returnStdout: true,
script: "ssh ${environment} 'cd /opt/amp_dbs && amp-db ls ${codeVersion} | sort'")
script: "ssh ${env.jenkinsUser}@${environment} 'cd /opt/amp_dbs && amp-db ls ${codeVersion} | sort'")
.trim()
if (countries == "") {
println "There are no database backups compatible with ${codeVersion}"
Expand All @@ -96,7 +101,7 @@ stage('Build') {

println "amp url is ${ampUrl}"

node {
node('docker') {
checkout scm

def image = "${dockerRepo}amp/webapp:${tag}"
Expand Down Expand Up @@ -135,19 +140,16 @@ stage('Build') {
}
}
}

def deployed = false

// If this stage fails then next stage will retry deployment. Otherwise next stage will be skipped.
stage('Deploy') {
node {
node('ansible') {
try {
// Find latest database version compatible with ${codeVersion}
dbVersion = sh(returnStdout: true, script: "ssh ${environment} 'cd /opt/amp_dbs && amp-db find ${codeVersion} ${country}'").trim()
dbVersion = sh(returnStdout: true, script: "ssh ${env.jenkinsUser}@${environment} 'cd /opt/amp_dbs && amp-db find ${codeVersion} ${country}'").trim()

// Deploy AMP
sh "ssh ${environment} 'amp-up2 ${tag} ${country} ${dbVersion} ${pgVersion}'"

sh "ssh ${env.jenkinsUser}@${environment} 'amp-up2 ${tag} ${country} ${dbVersion} ${pgVersion}'"
slackSend(channel: 'amp-ci', color: 'good', message: "Deploy AMP - Success\nDeployed ${changePretty} will be ready for testing at ${ampUrl} in about 3 minutes")

deployed = true
Expand All @@ -158,7 +160,6 @@ stage('Deploy') {
}
}
}

// Retry deploy with the same country.
stage('Deploy again') {
if (deployed) {
Expand All @@ -171,7 +172,7 @@ stage('Deploy again') {
}
node {
try {
sh "ssh ${environment} 'amp-up2 ${tag} ${country} ${dbVersion} ${pgVersion}'"
sh "ssh ${env.jenkinsUser}@${environment} 'amp-up2 ${tag} ${country} ${dbVersion} ${pgVersion}'"

slackSend(channel: 'amp-ci', color: 'good', message: "Deploy AMP - Success\nDeployed ${changePretty} will be ready for testing at ${ampUrl} in about 3 minutes")

Expand All @@ -183,4 +184,4 @@ stage('Deploy again') {
}
}
}
}
}

0 comments on commit d25b07e

Please sign in to comment.