[11.02.20] Basic outline of build pipeline

This commit is contained in:
andyjk15 2020-02-11 00:28:59 +00:00
parent 1fa031cb73
commit cb7a5b3515
3 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,73 @@
#!/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
}

View File

@ -0,0 +1,2 @@
#!/usr/bin/env groovy

View File

@ -0,0 +1,6 @@
<?xml version = "1.0" encoding = "UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
</settings>