diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ac865e3205a5af61a41082e2852dc212fa819ed1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM openjdk:8 +MAINTAINER haridas <haridas.kakunje@tarento.com> + +ADD zuul-0.0.1-SNAPSHOT.jar zuul-0.0.1-SNAPSHOT.jar +ENTRYPOINT ["java", "-jar", "/zuul-0.0.1-SNAPSHOT.jar"] +EXPOSE 8081 diff --git a/Dockerfile.build b/Dockerfile.build new file mode 100644 index 0000000000000000000000000000000000000000..30930e805b0c4bf048bb10a4e23c672d720b7c1e --- /dev/null +++ b/Dockerfile.build @@ -0,0 +1,7 @@ +FROM openjdk:8 + +RUN apt update && apt install maven -y + +COPY . /opt +WORKDIR /opt +RUN mvn clean install diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..f118342178732847dc67d5e6aef7898f65992771 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,52 @@ +node() { + try { + String ANSI_GREEN = "\u001B[32m" + String ANSI_NORMAL = "\u001B[0m" + String ANSI_BOLD = "\u001B[1m" + String ANSI_RED = "\u001B[31m" + String ANSI_YELLOW = "\u001B[33m" + + ansiColor('xterm') { + stage('Checkout') { + cleanWs() + checkout scm + commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + env.commit_id = sh(script: "echo " + "gateway" + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim() + echo "${env.commit_id}" + } + } + stage('docker-pre-build') { + sh ''' + + docker build --no-cache -f ./Dockerfile.build -t $docker_pre_build . + docker run --name $docker_pre_build $docker_pre_build:latest && docker cp $docker_pre_build:/opt/target/zuul-0.0.1-SNAPSHOT.jar . + docker rm -f $docker_pre_build + docker rmi -f $docker_pre_build + ''' + } + + stage('docker-build') { + sh ''' + docker build --no-cache -f Dockerfile -t $docker_server/$docker_repo:$commit_id . + ''' + } + stage('docker-push') { + + sh ''' + docker push $docker_server/$docker_repo:$commit_id + docker rmi -f $docker_server/$docker_repo:$commit_id + ''' + } + stage('ArchiveArtifacts') { + sh ("echo ${commit_id} > commit_id.txt") + archiveArtifacts "commit_id.txt" + currentBuild.description = "${commit_id}" + } + + +} + catch (err) { + currentBuild.result = "FAILURE" + throw err + } +}