Test new buil method

This commit is contained in:
Sebastien 2018-03-01 12:10:30 +01:00
parent d884f0cbbd
commit 4f35ff34d1
4 changed files with 44 additions and 10 deletions

View File

@ -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}

11
DownloadLast.sh Executable file
View File

@ -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 "(?<=<relativePath>)[^<]+" <<< "$data")
jarFile=$(grep -oPm1 "(?<=<fileName>)[^<]+" <<< "$data")
url="https://jenkins.seb6596.ovh/job/Bot%20Discord%20Gradle/lastStableBuild/artifact/"${relativePath}
echo ${url}
wget ${url} -O bot.jar

4
Jenkinsfile vendored
View File

@ -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
}
}

View File

@ -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"
}
}