[11.02.20] Basic outline of build pipeline
This commit is contained in:
parent
1fa031cb73
commit
cb7a5b3515
73
configuration/pipelines/build.groovy
Normal file
73
configuration/pipelines/build.groovy
Normal 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
|
||||
}
|
||||
2
configuration/pipelines/deploy.groovy
Normal file
2
configuration/pipelines/deploy.groovy
Normal file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env groovy
|
||||
|
||||
6
configuration/settings.xml
Normal file
6
configuration/settings.xml
Normal 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>
|
||||
Loading…
x
Reference in New Issue
Block a user