From 4f13d6cc64eed0ef75a31ec5f490853267447ab1 Mon Sep 17 00:00:00 2001 From: Venkata Harish K Kajur Date: Tue, 30 Jan 2018 13:52:34 -0500 Subject: Turn ajsc 2 to using ajsc 6 spring boot Issue-ID: AAI-800 Change-Id: Id174ec5088ddea57f18e605d004c417bee8fbf33 Signed-off-by: Venkata Harish K Kajur --- aai-resources/src/main/jenkins/Jenkinsfile | 31 ++++++++++++++++++++++++++ aai-resources/src/main/jenkins/build.groovy | 14 ++++++++++++ aai-resources/src/main/jenkins/checkout.groovy | 14 ++++++++++++ aai-resources/src/main/jenkins/deploy.groovy | 15 +++++++++++++ 4 files changed, 74 insertions(+) create mode 100644 aai-resources/src/main/jenkins/Jenkinsfile create mode 100644 aai-resources/src/main/jenkins/build.groovy create mode 100644 aai-resources/src/main/jenkins/checkout.groovy create mode 100644 aai-resources/src/main/jenkins/deploy.groovy (limited to 'aai-resources/src/main/jenkins') diff --git a/aai-resources/src/main/jenkins/Jenkinsfile b/aai-resources/src/main/jenkins/Jenkinsfile new file mode 100644 index 0000000..c74d439 --- /dev/null +++ b/aai-resources/src/main/jenkins/Jenkinsfile @@ -0,0 +1,31 @@ +node ("${BUILD_SLAVE}") { + // get the jenkinsfile root directory + def rootDir = pwd() + + def JAVA_HOME = tool 'jdk180' + env.PATH = "${JAVA_HOME}/bin:${env.PATH}" + sh 'which java' + sh 'java -version' + + env.DOCKER_HOST="tcp://localhost:4243" + + // load external groovy scripts + def build + def checkout + def deploy + dir('tmp') { + git url: "${GIT_URL}", branch: "${GIT_BRANCH}" + checkout = load 'src/main/jenkins/checkout.groovy' + build = load 'src/main/jenkins/build.groovy' + deploy = load 'src/main/jenkins/deploy.groovy' + } + + // check out code from git + checkout.gitCheckout() + + // build the git project + build.buildProject() + + deploy.deployService() + +} \ No newline at end of file diff --git a/aai-resources/src/main/jenkins/build.groovy b/aai-resources/src/main/jenkins/build.groovy new file mode 100644 index 0000000..3170510 --- /dev/null +++ b/aai-resources/src/main/jenkins/build.groovy @@ -0,0 +1,14 @@ + + +def buildProject() { + stage 'Build Git Project' + wrap([$class: 'ConfigFileBuildWrapper', managedFiles: [[fileId: 'eb0c7cc1-e851-4bc2-9401-2680c225f88c', targetLocation: '', variable: 'MAVEN_SETTINGS']]]) { + mvn '-s $MAVEN_SETTINGS -f pom.xml' +} +} + +def mvn(args) { + sh "${tool 'maven3'}/bin/mvn ${args} ${MAVEN_GOALS}" +} + +return this \ No newline at end of file diff --git a/aai-resources/src/main/jenkins/checkout.groovy b/aai-resources/src/main/jenkins/checkout.groovy new file mode 100644 index 0000000..ed439ec --- /dev/null +++ b/aai-resources/src/main/jenkins/checkout.groovy @@ -0,0 +1,14 @@ + +def gitCheckout() { + stage 'Checkout GIT' + //different ways to checkout + //checkout from master + //git "url: ${GIT_URL}, branch: ${GIT_BRANCH}" + //checkout from branch hardcoding" + //git branch: 'jenkins_deploy_test', credentialsId: 'b9bbafe5-53ce-4d2c-8b84-09137f75c592', url: 'https://codecloud.web.att.com/scm/st_ocnp/sdk-java-starter.git' + //checkout from branch parameters with credentials + //git branch: "${GIT_BRANCH}", credentialsId: 'b9bbafe5-53ce-4d2c-8b84-09137f75c592', url: "${GIT_URL}" + //checkout from branch parameters with no credentials + git branch: "${GIT_BRANCH}", url: "${GIT_URL}" +} +return this \ No newline at end of file diff --git a/aai-resources/src/main/jenkins/deploy.groovy b/aai-resources/src/main/jenkins/deploy.groovy new file mode 100644 index 0000000..1a000e3 --- /dev/null +++ b/aai-resources/src/main/jenkins/deploy.groovy @@ -0,0 +1,15 @@ +def deployService(){ + stage 'Deploying Service' + + // get the jenkinsfile root directory + def ROOT_DIR = pwd() + ROOT_DIR = "${ROOT_DIR}"+'/src/main/kubernetes' + echo "ROOTDIR : ${ROOT_DIR}" + sh "/opt/app/kubernetes/v1.3.4/bin/kubectl --kubeconfig=${ROOT_DIR}/kubectl.conf replace --force --cascade -f ${ROOT_DIR}/${artifactId}-svc.yaml" + sh "/opt/app/kubernetes/v1.3.4/bin/kubectl --kubeconfig=${ROOT_DIR}/kubectl.conf replace --force --cascade -f ${ROOT_DIR}/${artifactId}-rc.yaml" +} +return this + + + + -- cgit 1.2.3-korg