summaryrefslogtreecommitdiffstats
path: root/src/main/jenkins
diff options
context:
space:
mode:
authorLaMont, William (wl2432) <wl2432@us.att.com>2018-08-31 10:56:17 -0400
committerLaMont, William (wl2432) <wl2432@us.att.com>2018-08-31 11:10:32 -0400
commit571d6f65cf5e0e5334956dbe11730fd47820b947 (patch)
treeca23e0f64ca2968b4a933cb6a0bb0b4781bc24e8 /src/main/jenkins
parent6ed92ea7526678f245a9123d2ee97a6a9e2c3bf1 (diff)
initial code for cacher
Issue-ID: AAI-1473 Change-Id: I8babe91e79f5c1e6e97b0f5b6dc827b8c5caec80 Signed-off-by: LaMont, William (wl2432) <wl2432@att.com>
Diffstat (limited to 'src/main/jenkins')
-rw-r--r--src/main/jenkins/Jenkinsfile31
-rw-r--r--src/main/jenkins/build.groovy14
-rw-r--r--src/main/jenkins/checkout.groovy14
-rw-r--r--src/main/jenkins/deploy.groovy15
4 files changed, 74 insertions, 0 deletions
diff --git a/src/main/jenkins/Jenkinsfile b/src/main/jenkins/Jenkinsfile
new file mode 100644
index 0000000..c74d439
--- /dev/null
+++ b/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/src/main/jenkins/build.groovy b/src/main/jenkins/build.groovy
new file mode 100644
index 0000000..3170510
--- /dev/null
+++ b/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/src/main/jenkins/checkout.groovy b/src/main/jenkins/checkout.groovy
new file mode 100644
index 0000000..ed439ec
--- /dev/null
+++ b/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/src/main/jenkins/deploy.groovy b/src/main/jenkins/deploy.groovy
new file mode 100644
index 0000000..1a000e3
--- /dev/null
+++ b/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
+
+
+
+