[19.02.20] Dynamic Shell Scripts
This commit is contained in:
parent
adb2382a68
commit
41f3ca8ded
@ -27,6 +27,10 @@ String get_application_version() {
|
||||
"${pom.version}-b${env.BUILD_NUMBER}"
|
||||
}
|
||||
|
||||
String executeShellScript( String shellPath, String arg1 = '', String arg2 = '', String arg3 = '', String arg4 = '' ) {
|
||||
sh "./${shellPath} ${arg1} ${arg2} ${arg3} ${arg4}"
|
||||
}
|
||||
|
||||
try {
|
||||
timestamps {
|
||||
node ("${env.SLAVE_LABEL}") {
|
||||
@ -44,7 +48,7 @@ try {
|
||||
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"
|
||||
}
|
||||
}
|
||||
@ -64,18 +68,16 @@ try {
|
||||
stage('Build Image') {
|
||||
mvn 'clean package -DskipTests'
|
||||
|
||||
sh "sed -i 's/REPOSITORY/${env.DOCKER_REPOSITORY}/g' configuration/kubernetes/deployment.yaml"
|
||||
sh "sed -i 's/IMAGE/${env.APPLICATION_NAME}:${env.APPLICATION_VERSION}/g' configuration/kubernetes/deployment.yaml"
|
||||
sh "sed -i 's/RESOURCE_NAME/${env.APPLICATION_NAME}/g' configuration/kubernetes/deployment.yaml"
|
||||
sh "sed -i 's/LABEL/${env.APPLICATION_LABEL}/g' configuration/kubernetes/deployment.yaml"
|
||||
|
||||
sh "sed -it 's/RESOURCE_NAME/${env.APPLICATION_NAME}/g' configuration/kubernetes/service.yaml"
|
||||
sh "sed -it 's/LABEL/${env.APPLICATION_LABEL}/g' configuration/kubernetes/service.yaml"
|
||||
executeShellScript("configuration/kubernetes/mapVarsToConfigs.sh",
|
||||
env.DOCKER_REPOSITORY,
|
||||
env.APPLICATION_NAME,
|
||||
env.APPLICATION_VERSION,
|
||||
env.APPLICATION_LABEL)
|
||||
}
|
||||
|
||||
stage('Tag Repository') {
|
||||
|
||||
withDockerServer([uri: "tcp://registry.cryptosky.me:4243"]) {
|
||||
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()
|
||||
|
||||
2
configuration/scripts/deployToKubernetes.sh
Normal file
2
configuration/scripts/deployToKubernetes.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
14
configuration/scripts/mapVarsToConfigs.sh
Normal file
14
configuration/scripts/mapVarsToConfigs.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DOCKER_REPOSITORY=$1
|
||||
APPLICATION_NAME=$2
|
||||
APPLICATION_VERSION=$3
|
||||
APPLICATION_LABEL=$4
|
||||
|
||||
sh "sed -i 's/REPOSITORY/${DOCKER_REPOSITORY}/g' configuration/kubernetes/deployment.yaml"
|
||||
sh "sed -i 's/IMAGE/${APPLICATION_NAME}:${APPLICATION_VERSION}/g' configuration/kubernetes/deployment.yaml"
|
||||
sh "sed -i 's/RESOURCE_NAME/${APPLICATION_NAME}/g' configuration/kubernetes/deployment.yaml"
|
||||
sh "sed -i 's/LABEL/${APPLICATION_LABEL}/g' configuration/kubernetes/deployment.yaml"
|
||||
|
||||
sh "sed -it 's/RESOURCE_NAME/${APPLICATION_NAME}/g' configuration/kubernetes/service.yaml"
|
||||
sh "sed -it 's/LABEL/${APPLICATION_LABEL}/g' configuration/kubernetes/service.yaml"
|
||||
Loading…
x
Reference in New Issue
Block a user