[19.02.20] Indentation and adding github tagging
This commit is contained in:
parent
02199119f4
commit
a3267fa992
@ -28,71 +28,80 @@ String executeShellScript( String shellPath, String arg1 = '', String arg2 = '',
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
timestamps {
|
timestamps {
|
||||||
node ("${env.SLAVE_LABEL}") {
|
node ("${env.SLAVE_LABEL}") {
|
||||||
stage('Initialise') {
|
stage('Initialise') {
|
||||||
checkout([$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'Github', url: 'https://github.com/andyjk15/db-gateway.git']]])
|
checkout([$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'Github', url: 'https://github.com/andyjk15/db-gateway.git']]])
|
||||||
|
|
||||||
env.APPLICATION_VERSION = get_application_version()
|
env.APPLICATION_VERSION = get_application_version()
|
||||||
|
|
||||||
mvn '--version'
|
mvn '--version'
|
||||||
|
|
||||||
withCredentials(
|
withCredentials(
|
||||||
[usernamePassword(
|
[usernamePassword(
|
||||||
credentialsId: 'doctl',
|
credentialsId: 'doctl',
|
||||||
passwordVariable: 'DOCTL_TOKEN',
|
passwordVariable: 'DOCTL_TOKEN',
|
||||||
usernameVariable: 'DOCTL_USERNAME'
|
usernameVariable: 'DOCTL_USERNAME'
|
||||||
)]
|
)]
|
||||||
) {
|
) {
|
||||||
sh "doctl auth init --access-token ${DOCTL_TOKEN}"
|
sh "doctl auth init --access-token ${DOCTL_TOKEN}"
|
||||||
sh "doctl kubernetes cluster kubeconfig save cryptosky-kubernetes-cluster-production"
|
sh "doctl kubernetes cluster kubeconfig save cryptosky-kubernetes-cluster-production"
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build Artifact') {
|
|
||||||
mvn 'compile'
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Test Artifact') {
|
|
||||||
try {
|
|
||||||
mvn 'verify -DskipUTs -DskipTests'
|
|
||||||
} finally {
|
|
||||||
mvn 'test'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Build Image') {
|
|
||||||
mvn 'clean package -DskipTests'
|
|
||||||
|
|
||||||
executeShellScript("configuration/scripts/mapVarsToConfigs.sh",
|
|
||||||
env.DOCKER_REPOSITORY,
|
|
||||||
env.APPLICATION_NAME,
|
|
||||||
env.APPLICATION_VERSION,
|
|
||||||
env.APPLICATION_LABEL)
|
|
||||||
|
|
||||||
sh "cat configuration/kubernetes/deployment.yaml"
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Deploy') {
|
|
||||||
sh "kubectl apply -f configuration/kubernetes/deployment.yaml"
|
|
||||||
sh "kubectl apply -f configuration/kubernetes/service.yaml"
|
|
||||||
|
|
||||||
sh "kubectl get pods"
|
|
||||||
|
|
||||||
sh "kubectl rollout status deployment/${env.APPLICATION_NAME}"
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Tag Repository') {
|
|
||||||
|
|
||||||
withDockerServer([uri: "${env.DOCKER_REPOSITORY_TCP}"]) {
|
|
||||||
withDockerRegistry([credentialsId: 'Registry', url: "${env.DOCKER_REPOSITORY_URL}"]) {
|
|
||||||
def image = docker.build("${env.DOCKER_REPOSITORY}/db-gateway:${env.APPLICATION_VERSION}")
|
|
||||||
image.push()
|
|
||||||
def latest = docker.build("${env.DOCKER_REPOSITORY}/db-gateway:latest")
|
|
||||||
latest.push()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Build Artifact') {
|
||||||
|
mvn 'compile'
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Test Artifact') {
|
||||||
|
try {
|
||||||
|
mvn 'verify -DskipUTs -DskipTests'
|
||||||
|
} finally {
|
||||||
|
mvn 'test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Image') {
|
||||||
|
mvn 'clean package -DskipTests'
|
||||||
|
|
||||||
|
executeShellScript("configuration/scripts/mapVarsToConfigs.sh",
|
||||||
|
env.DOCKER_REPOSITORY,
|
||||||
|
env.APPLICATION_NAME,
|
||||||
|
env.APPLICATION_VERSION,
|
||||||
|
env.APPLICATION_LABEL)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Deploy') {
|
||||||
|
sh "kubectl apply -f configuration/kubernetes/deployment.yaml"
|
||||||
|
sh "kubectl apply -f configuration/kubernetes/service.yaml"
|
||||||
|
|
||||||
|
sh "kubectl get pods"
|
||||||
|
|
||||||
|
sh "kubectl rollout status deployment/${env.APPLICATION_NAME}"
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Tag Repository') {
|
||||||
|
|
||||||
|
withDockerServer([uri: "${env.DOCKER_REPOSITORY_TCP}"]) {
|
||||||
|
withDockerRegistry([credentialsId: 'Registry', url: "${env.DOCKER_REPOSITORY_URL}"]) {
|
||||||
|
def image = docker.build("${env.DOCKER_REPOSITORY}/db-gateway:${env.APPLICATION_VERSION}")
|
||||||
|
image.push()
|
||||||
|
def latest = docker.build("${env.DOCKER_REPOSITORY}/db-gateway:latest")
|
||||||
|
latest.push()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
withCredentials(
|
||||||
|
[usernamePassword(
|
||||||
|
credentialsId: env.GITHUB_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 ) {
|
} catch ( exception ) {
|
||||||
currentBuild.result = 'FAILURE'
|
currentBuild.result = 'FAILURE'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user