73 lines
2.0 KiB
Groovy
73 lines
2.0 KiB
Groovy
#!/usr/bin/env groovy
|
|
|
|
env.APPLICATION_NAME = 'db-gateway'
|
|
env.APPLICATION_LABEL = 'gateways'
|
|
env.GIT_BRANCH = 'master'
|
|
env.GIT_REPOSITORY_PATH = "github.com/andyjk15/${env.APPLICATION_NAME}.git"
|
|
env.GIT_REPOSITORY_URL = "https://${env.GIT_REPOSITORY_PATH}"
|
|
env.GITHUB_CREDENTIALS_ID = 'cryptosky-admin'
|
|
env.DOCKER_REPOSITORY = 'https://registry.cryptosky.me'
|
|
|
|
env.NAMESPACE = 'production'
|
|
env.SLAVE_LABEL = "cryptosky-aio-build"
|
|
|
|
env.CPU_REQUESTS = '1'
|
|
env.CPU_LIMIT = '2'
|
|
env.RAM_REQUEST = '500MiB'
|
|
env.RAM_LIMIT = '1Gi'
|
|
|
|
def mvn( String gloals ) {
|
|
sh "mvn -s configuration/settings.xml --show-version --batch-mode ${gloals}"
|
|
}
|
|
|
|
String get_application_version() {
|
|
pom = readMavenPom file: 'pom.xml'
|
|
"${pom.version}-b${env.BUILD_NUMBER}"
|
|
}
|
|
|
|
try {
|
|
node ("${env.SLAVE_LABEL}") {
|
|
stage('Initialise') {
|
|
git url: env.GIT_REPOSITORY_URL, branch: env.GIT_BRANCH, credentialsId: env.GITHUB_CREDENTIALS_ID
|
|
|
|
env.APPLICATION_VERSION = get_application_version()
|
|
|
|
mvn '--version'
|
|
}
|
|
|
|
stage('Build Artifact') {
|
|
mvn 'compile'
|
|
}
|
|
|
|
stage('Test Artifact') {
|
|
try {
|
|
mvn 'verify'
|
|
} finally {
|
|
mvn 'test'
|
|
}
|
|
}
|
|
|
|
stage('Build Image') {
|
|
mvn 'clean package -DskipTests'
|
|
}
|
|
|
|
stage('Deploy') {
|
|
|
|
}
|
|
|
|
stage('Tag Repository') {
|
|
withCredentials(
|
|
[usernamePassword(
|
|
credentialsId: env.BITBUCKET_CREDENTIALS_ID,
|
|
passwordVariable: 'GIT_PASSWORD',
|
|
usernameVariable: 'GIT_USERNAME'
|
|
)]
|
|
) {
|
|
sh "git tag ${env.APPLICATION_VERSION}"
|
|
sh "git push https://${GIT_USERNAME}:${GIT_PASSWORD}@${env.GIT_REPOSITORY_PATH} ${env.APPLICATION_VERSION}"
|
|
}
|
|
}
|
|
}
|
|
} catch ( exception ) {
|
|
throw exception
|
|
} |