[19.02.20] Secret for repository revert

This commit is contained in:
andyjk15 2020-02-19 11:27:55 +00:00
parent 42f82f8937
commit b1b52dec23
2 changed files with 68 additions and 75 deletions

View File

@ -72,4 +72,4 @@ spec:
memory: 256Mi memory: 256Mi
restartPolicy: Always restartPolicy: Always
imagePullSecrets: imagePullSecrets:
- name: $KUBERNETES_SECRET_NAME - name: registry-secret

View File

@ -46,87 +46,80 @@ def deploy( Integer replicas ) {
} }
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'
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"
}
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.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}"
// }
}
stage('Deploy') { stage('Build Artifact') {
sh "kubectl apply -f configuration/kubernetes/deployment.yaml" mvn 'compile'
sh "kubectl apply -f configuration/kubernetes/service.yaml" }
sh "kubectl get pods" stage('Test Artifact') {
// kubernetesDeploy configs: '**/configuration/kubernetes/*.yaml', try {
// deleteResource: true, mvn 'verify -DskipUTs -DskipTests'
// dockerCredentials: [[credentialsId: 'Registry', url: "${env.DOCKER_REPOSITORY_URL}"]], } finally {
// kubeConfig: [path: ''], mvn 'test'
// kubeconfigId: 'Kubernetes', }
//// secretName: '', }
// ssh: [sshCredentialsId: '*', sshServer: ''],
// textCredentials: [certificateAuthorityData: '', clientCertificateData: '', clientKeyData: '', serverUrl: 'https://'] 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"
}
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.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}"
// }
}
stage('Deploy') {
sh "kubectl apply -f configuration/kubernetes/deployment.yaml"
sh "kubectl apply -f configuration/kubernetes/service.yaml"
sh "kubectl get pods"
}
} }
} }
} catch ( exception ) { } catch ( exception ) {