[08.10.20] Pipeline fixes
This commit is contained in:
parent
9c4b3c3de9
commit
7f4da8552e
@ -6,30 +6,28 @@ 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 = 'Github'
|
||||
env.DOCKER_REPOSITORY = 'registry.cryptosky.me'
|
||||
env.DOCKER_REPOSITORY_URL = "https://${env.DOCKER_REPOSITORY}"
|
||||
env.DOCKER_REPOSITORY_TCP = "tcp://${env.DOCKER_REPOSITORY}:4243"
|
||||
env.DIGITAL_OCEAN = 'registry.digitalocean.com'
|
||||
env.DIGITAL_OCEAN_REPO = 'cryptosky-image-registry'
|
||||
env.DOCKER_BUILDER = 'registry.cryptosky.me'
|
||||
env.DOCKER_REPOSITORY = "${env.DIGITAL_OCEAN}/${env.DIGITAL_OCEAN_REPO}"
|
||||
env.DOCKER_REPOSITORY_TCP = "tcp://${env.DOCKER_BUILDER}:4243"
|
||||
|
||||
env.NAMESPACE = 'production'
|
||||
env.SLAVE_LABEL = "cryptosky-aio-build"
|
||||
|
||||
def mvn( String gloals ) {
|
||||
sh "mvn -s configuration/settings.xml --show-version --batch-mode ${gloals}"
|
||||
}
|
||||
|
||||
String get_application_version() {
|
||||
"1.0.0-b${env.BUILD_NUMBER}"
|
||||
}
|
||||
|
||||
String executeShellScript( String shellPath, String arg1 = '', String arg2 = '', String arg3 = '', String arg4 = '' ) {
|
||||
sh "./${shellPath} ${arg1} ${arg2} ${arg3} ${arg4}"
|
||||
String executeShellScript( String shellPath, String arg1 = '', String arg2 = '', String arg3 = '', String arg4 = '', String arg5 = '' ) {
|
||||
sh "./${shellPath} ${arg1} ${arg2} ${arg3} ${arg4} ${arg5}"
|
||||
}
|
||||
|
||||
try {
|
||||
timestamps {
|
||||
node ("${env.SLAVE_LABEL}") {
|
||||
stage('Initialise') {
|
||||
checkout([$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'Github', url: 'https://github.com/andyjk15/spam-filter.git']]])
|
||||
checkout([$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'Github', url: env.GIT_REPOSITORY_URL]]])
|
||||
|
||||
env.APPLICATION_VERSION = get_application_version()
|
||||
|
||||
@ -41,39 +39,35 @@ try {
|
||||
)]
|
||||
) {
|
||||
sh "doctl auth init --access-token ${DOCTL_TOKEN}"
|
||||
sh "doctl kubernetes cluster kubeconfig save cryptosky-kubernetes-cluster-production"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Test Artifact') {
|
||||
try {
|
||||
// mvn 'verify -DskipUTs -DskipTests'
|
||||
} finally {
|
||||
// mvn 'test'
|
||||
sh "doctl registry login"
|
||||
sh "doctl kubernetes cluster kubeconfig save cryptosky-cluster"
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Image') {
|
||||
// mvn 'clean package -DskipTests'
|
||||
|
||||
executeShellScript("configuration/scripts/mapVarsToConfigs.sh",
|
||||
env.DOCKER_REPOSITORY,
|
||||
env.DIGITAL_OCEAN,
|
||||
env.DIGITAL_OCEAN_REPO,
|
||||
env.APPLICATION_NAME,
|
||||
env.APPLICATION_VERSION,
|
||||
env.APPLICATION_LABEL)
|
||||
|
||||
withDockerServer([uri: "${env.DOCKER_REPOSITORY_TCP}"]) {
|
||||
docker.build("${env.APPLICATION_NAME}:${env.APPLICATION_VERSION}")
|
||||
docker.build("${env.APPLICATION_NAME}:latest")
|
||||
|
||||
sh "docker tag ${env.APPLICATION_NAME}:${env.APPLICATION_VERSION} ${env.DOCKER_REPOSITORY}/${env.APPLICATION_NAME}:${env.APPLICATION_VERSION}"
|
||||
sh "docker tag ${env.APPLICATION_NAME}:latest ${env.DOCKER_REPOSITORY}/${env.APPLICATION_NAME}:latest"
|
||||
|
||||
sh "docker push ${env.DOCKER_REPOSITORY}/${env.APPLICATION_NAME}:${env.APPLICATION_VERSION}"
|
||||
sh "docker push ${env.DOCKER_REPOSITORY}/${env.APPLICATION_NAME}:latest"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
stage('Tag Repository') {
|
||||
|
||||
withDockerServer([uri: "${env.DOCKER_REPOSITORY_TCP}"]) {
|
||||
withDockerRegistry([credentialsId: 'Registry', url: "${env.DOCKER_REPOSITORY_URL}"]) {
|
||||
def image = docker.build("${env.DOCKER_REPOSITORY}/${env.APPLICATION_NAME}:${env.APPLICATION_VERSION}")
|
||||
image.push()
|
||||
def latest = docker.build("${env.DOCKER_REPOSITORY}/${env.APPLICATION_NAME}:latest")
|
||||
latest.push()
|
||||
}
|
||||
}
|
||||
withCredentials(
|
||||
[usernamePassword(
|
||||
credentialsId: env.GITHUB_CREDENTIALS_ID,
|
||||
|
||||
@ -5,6 +5,4 @@ APPLICATION_NAME=$1
|
||||
kubectl apply -f configuration/kubernetes/deployment.yaml
|
||||
kubectl apply -f configuration/kubernetes/service.yaml
|
||||
|
||||
kubectl get pods
|
||||
|
||||
kubectl rollout status deployment/${APPLICATION_NAME} --namespace=production
|
||||
@ -1,9 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DOCKER_REPOSITORY=$1
|
||||
APPLICATION_NAME=$2
|
||||
APPLICATION_VERSION=$3
|
||||
APPLICATION_LABEL=$4
|
||||
DIGITAL_OCEAN=$1
|
||||
DIGITAL_OCEAN_REPO=$2
|
||||
APPLICATION_NAME=$3
|
||||
APPLICATION_VERSION=$4
|
||||
APPLICATION_LABEL=$5
|
||||
|
||||
DOCKER_REPOSITORY="${DIGITAL_OCEAN}\/${DIGITAL_OCEAN_REPO}"
|
||||
|
||||
sed -i "s/REPOSITORY/${DOCKER_REPOSITORY}/g" configuration/kubernetes/deployment.yaml
|
||||
sed -i "s/IMAGE/${APPLICATION_NAME}:${APPLICATION_VERSION}/g" configuration/kubernetes/deployment.yaml
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user