-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug where discord intents break JDA library
- Loading branch information
Showing
5 changed files
with
125 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ FROM centos:7 | |
RUN yum update clean all | ||
RUN yum -y install java-1.8.0-openjdk-devel.x86_64 | ||
RUN yum -y install maven | ||
RUN yum -y install git | ||
RUN adduser jenkins | ||
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk | ||
"""; | ||
|
@@ -21,46 +22,109 @@ def getChangelistDescription() { | |
} | ||
|
||
def getNextVersion() { | ||
def latestVersion = readFile "${env.WORKSPACE}/version.txt" | ||
def latestVersion = readFile "${env.WORKSPACE}/src/main/resources/version.txt" | ||
print "version=" + latestVersion; | ||
def (major, minor, patch) = latestVersion.tokenize('.').collect { it.toInteger() }; | ||
print "major=" + major + ",minor=" + minor + ",patch=" + patch; | ||
print "next version: major=" + major + ",minor=" + minor + ",patch=" + (patch + 1); | ||
return "${major}.${minor}.${patch + 1}"; | ||
} | ||
|
||
node { | ||
try { | ||
// whether or not to deploy to github & dockerhub | ||
def deploy; | ||
// the version being built/released | ||
def tag; | ||
// the docker image | ||
def image; | ||
|
||
def email; | ||
withCredentials([string(credentialsId: 'botdarr-email', variable: 'botdarr_email')]) { | ||
email = "${botdarr_email}"; | ||
} | ||
|
||
def username; | ||
withCredentials([string(credentialsId: 'botdarr-username', variable: 'botdarr_username')]) { | ||
username = "${botdarr_username}"; | ||
} | ||
|
||
pipeline { | ||
agent any | ||
stages { | ||
stage("Checkout") { | ||
checkout([$class: 'GitSCM', branches: [[name: '**']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github', url: 'https://github.com/shayaantx/botdar.git']]]) | ||
steps { | ||
script { | ||
checkout([$class: 'GitSCM', branches: [[name: '**']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'github', url: "https://github.com/${username}/botdar.git"]]]) | ||
env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim() | ||
deploy = !env.GIT_COMMIT_MSG.startsWith("Update version to") && env.BRANCH_NAME == "development"; | ||
} | ||
} | ||
} | ||
|
||
stage('Prepare docker') { | ||
fileOperations([fileCreateOperation(fileContent: "${dockerFileContents}", fileName: './Dockerfile')]); | ||
steps { | ||
script { | ||
fileOperations([fileCreateOperation(fileContent: "${dockerFileContents}", fileName: './Dockerfile')]); | ||
tag = getNextVersion(); | ||
image = docker.build("botdarr-image", "-f ./Dockerfile ."); | ||
} | ||
} | ||
} | ||
|
||
def tag = getNextVersion(); | ||
def image = docker.build("botdarr-image", "-f ./Dockerfile ."); | ||
image.inside('-u root') { | ||
stage('Build') { | ||
sh './mvnw --no-transfer-progress compile' | ||
stage('Build') { | ||
steps { | ||
script { | ||
image.inside('-u root') { | ||
sh './mvnw --no-transfer-progress compile' | ||
} | ||
} | ||
} | ||
|
||
stage("Test") { | ||
sh './mvnw --no-transfer-progress test' | ||
} | ||
stage('Test') { | ||
steps { | ||
script { | ||
image.inside('-u root') { | ||
sh './mvnw --no-transfer-progress test' | ||
} | ||
} | ||
} | ||
|
||
stage("Package") { | ||
fileOperations([fileCreateOperation(fileContent: "version=${tag}", fileName: './src/main/resources/version.txt')]); | ||
sh './mvnw --no-transfer-progress package -DskipTests' | ||
} | ||
stage('Package') { | ||
steps { | ||
script { | ||
image.inside('-u root') { | ||
sh "echo ${tag} > ./src/main/resources/version.txt" | ||
sh './mvnw --no-transfer-progress package -DskipTests' | ||
archiveArtifacts 'target/botdarr-release.jar' | ||
} | ||
} | ||
} | ||
|
||
stage("Archive") { | ||
archiveArtifacts 'target/botdarr-release.jar' | ||
} | ||
|
||
stage('Update version') { | ||
when { | ||
expression { | ||
return deploy | ||
} | ||
} | ||
|
||
if (env.BRANCH_NAME == "development") { | ||
//don't upload for PR's | ||
stage('Create/Upload Release') { | ||
steps { | ||
sshagent(['jenkins-ssh-key-github']) { | ||
sh "git remote set-url origin [email protected]:${username}/botdarr.git" | ||
sh "git config --global user.name ${username}" | ||
sh "git config --global user.email ${email}" | ||
sh "ssh -oStrictHostKeyChecking=no ${username}@github.com || true" | ||
sh "git add src/main/resources/version.txt" | ||
sh "git commit -m \"Update version to ${tag}\"" | ||
sh "git push origin HEAD:${env.BRANCH_NAME}" | ||
} | ||
} | ||
} | ||
|
||
stage('Create/Upload Release') { | ||
when { | ||
expression { | ||
return deploy | ||
} | ||
} | ||
steps { | ||
script { | ||
withCredentials([string(credentialsId: 'git-token', variable: 'token')]) { | ||
def description = getChangelistDescription(); | ||
print "description=" + description; | ||
|
@@ -72,35 +136,42 @@ node { | |
} | ||
} | ||
} | ||
|
||
stage('Upload to dockerhub') { | ||
when { | ||
expression { | ||
return deploy | ||
} | ||
} | ||
steps { | ||
script { | ||
def dockerFileImage = """ | ||
FROM centos:7 | ||
RUN yum update; yum clean all; yum -y install java-1.8.0-openjdk-devel.x86_64; | ||
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk | ||
ENV PATH=$PATH:$JAVA_HOME/bin | ||
if (env.BRANCH_NAME == "development") { | ||
//don't upload for PR's | ||
stage('Upload to dockerhub') { | ||
def dockerFileImage = """ | ||
FROM centos:7 | ||
RUN yum update; yum clean all; yum -y install java-1.8.0-openjdk-devel.x86_64; | ||
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk | ||
ENV PATH=$PATH:$JAVA_HOME/bin | ||
RUN mkdir -p /home/botdarr | ||
ADD target/botdarr-release.jar /home/botdarr | ||
RUN mkdir -p /home/botdarr | ||
ADD target/botdarr-release.jar /home/botdarr | ||
WORKDIR /home/botdarr | ||
RUN java -version | ||
WORKDIR /home/botdarr | ||
RUN java -version | ||
ENTRYPOINT ["java", "-jar", "botdarr-release.jar"] | ||
"""; | ||
fileOperations([fileCreateOperation(fileContent: "${dockerFileImage}", fileName: './DockerfileUpload')]); | ||
def releaseTag = "latest"; | ||
def imageWithReleaseTag = docker.build("shayaantx/botdarr:${releaseTag}", "-f ./DockerfileUpload ."); | ||
withDockerRegistry(credentialsId: 'docker-credentials') { | ||
imageWithReleaseTag.push(); | ||
ENTRYPOINT ["java", "-jar", "botdarr-release.jar"] | ||
"""; | ||
fileOperations([fileCreateOperation(fileContent: "${dockerFileImage}", fileName: './DockerfileUpload')]); | ||
def releaseTag = "latest"; | ||
def imageWithReleaseTag = docker.build("${username}/botdarr:${releaseTag}", "-f ./DockerfileUpload ."); | ||
withDockerRegistry(credentialsId: 'docker-credentials') { | ||
imageWithReleaseTag.push(); | ||
} | ||
} | ||
} | ||
} | ||
} finally { | ||
stage("Cleanup") { | ||
deleteDir(); | ||
} | ||
post { | ||
always { | ||
deleteDir() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5.0.5 |
This file was deleted.
Oops, something went wrong.