From 4f35ff34d197806bc70016896034395dbf2ee089 Mon Sep 17 00:00:00 2001 From: Sebastien Date: Thu, 1 Mar 2018 12:10:30 +0100 Subject: [PATCH] Test new buil method --- Dockerfile | 11 +++++------ DownloadLast.sh | 11 +++++++++++ Jenkinsfile | 4 +++- build.gradle | 28 +++++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 10 deletions(-) create mode 100755 DownloadLast.sh diff --git a/Dockerfile b/Dockerfile index 8e99f41..aab218d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,11 @@ FROM debian:latest -#RUN apt-key update RUN apt-get update RUN apt-get -y upgrade -RUN apt-get -y install openjdk-8-jre openjdk-8-jdk +RUN apt-get -y install openjdk-8-jre openjdk-8-jdk curl wget WORKDIR /bot_src -ADD . /bot_src/ -RUN chmod +x gradlew +ADD DownloadLast.sh /bot_src/ +RUN chmod +x DownloadLast.sh +RUN ./DownloadLast.sh ENV PORT=8080 ENV TOKEN=10 -RUN ./gradlew build -CMD java -jar build/libs/DiscordBot-0.1.0.jar -t ${TOKEN} +CMD java -jar bot.jar -t ${TOKEN} diff --git a/DownloadLast.sh b/DownloadLast.sh new file mode 100755 index 0000000..d15ecbd --- /dev/null +++ b/DownloadLast.sh @@ -0,0 +1,11 @@ +#!/bin/bash +#This script download the last stable build on jenkins + +data=$(curl -g "https://jenkins.seb6596.ovh/job/Bot%20Discord%20Gradle/lastStableBuild/api/xml?xpath=/freeStyleBuild/artifact&wrapper=artifacts") +relativePath=$(grep -oPm1 "(?<=)[^<]+" <<< "$data") +jarFile=$(grep -oPm1 "(?<=)[^<]+" <<< "$data") +url="https://jenkins.seb6596.ovh/job/Bot%20Discord%20Gradle/lastStableBuild/artifact/"${relativePath} +echo ${url} +wget ${url} -O bot.jar + + diff --git a/Jenkinsfile b/Jenkinsfile index 4c94390..e2aad3b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,9 @@ node { // Get some code from a GitHub repository git 'https://github.com/BrokenFire/BrokenDiscordBot.git' } + stage('Gradle Buil){ + build job: 'Bot Discord Gradle', wait: true + } stage('Build image') { /* This builds the actual image; synonymous to * docker build on the command line */ @@ -20,6 +23,5 @@ node { } stage('Cleaning'){ sh "docker image prune -f" - build job: 'Bot Discord javadoc', wait: false } } diff --git a/build.gradle b/build.gradle index 0983c50..7f33b70 100644 --- a/build.gradle +++ b/build.gradle @@ -13,9 +13,21 @@ apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'org.springframework.boot' + +def versionObj = new Version(major: 0, minor: 2, revision: 0) + +group = "net.broken" +archivesBaseName = "BrokenDiscordBot" +version = "$versionObj" + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + + + jar { baseName = 'DiscordBot' - version = '0.1.0' + } repositories { @@ -28,8 +40,6 @@ javadoc { classpath = configurations.compile } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 dependencies { compile("org.springframework.boot:spring-boot-starter-web"){ @@ -56,3 +66,15 @@ dependencies { } } +class Version { + String major, minor, revision + + static String getBuild() { + System.getenv("BUILD_NUMBER") ?: System.getProperty("BUILD_NUMBER") ?: + System.getenv("GIT_COMMIT")?.substring(0, 7) ?: System.getProperty("GIT_COMMIT")?.substring(0, 7) ?:"DEV" + } + + String toString() { + "${major}.${minor}.${revision}_$build" + } +} \ No newline at end of file