Skip to content

Commit

Permalink
Add jenkins file, change version number to be based on tags. And publ…
Browse files Browse the repository at this point in the history
…ish to Forge maven.
  • Loading branch information
LexManos committed Sep 5, 2018
1 parent 359efd0 commit 52f4e47
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
55 changes: 55 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@Library('forge-shared-library')_

pipeline {
agent {
docker {
image 'gradlewrapper:latest'
args '-v gradlecache:/gradlecache'
}
}
environment {
GRADLE_ARGS = '-Dorg.gradle.daemon.idletimeout=5000'
}

stages {
stage('fetch') {
steps {
git(url: 'https://github.com/MinecraftForge/ForgeGradle.git', changelog: true)
}
}
stage('buildandtest') {
steps {
sh './gradlew ${GRADLE_ARGS} --refresh-dependencies --continue build test'
script {
env.MYVERSION = sh(returnStdout: true, script: './gradlew properties -q | grep "version:" | awk \'{print $2}\'').trim()
}
}
post {
success {
writeChangelog(currentBuild, 'build/changelog.txt')
archiveArtifacts artifacts: 'build/changelog.txt', fingerprint: false
}
}
}
stage('publish') {
when {
not {
changeRequest()
}
}
environment {
FORGE_MAVEN = credentials('forge-maven-forge-user')
}
steps {
sh './gradlew ${GRADLE_ARGS} publish -PforgeMavenUser=${FORGE_MAVEN_USR} -PforgeMavenPassword=${FORGE_MAVEN_PSW}'
}
}
}
post {
always {
archiveArtifacts artifacts: 'build/libs/**/*.jar', fingerprint: true
junit 'build/test-results/*/*.xml'
jacoco sourcePattern: '**/src/*/java'
}
}
}
28 changes: 25 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
plugins {
//id 'net.minecrell.licenser' version '0.3'
id 'org.ajoberstar.grgit' version '2.3.0'
//id 'com.github.johnrengelman.shadow' version '2.0.4'
}

apply plugin: 'java'
apply plugin: 'maven-publish'

group = 'net.minecraftforge.gradle'
version = '3.0.0-SNAPSHOT'
version = gitVersion()
def gitVersion() {
def desc = grgit.describe(longDescr: true).split('-') as List
def hash = desc.remove(desc.size() - 1)
def offset = desc.remove(desc.size() - 1)
def tag = desc.join('-')
def branch = grgit.branch.current().name
return "${tag}.${offset}${t -> if (branch != 'master') t << '-' + branch}"
}

sourceSets {
common
Expand Down Expand Up @@ -58,7 +72,15 @@ publishing {
}
repositories {
maven {
url "$buildDir/repo"
if (project.hasProperty('forgeMavenPassword')) {
credentials {
username project.properties.forgeMavenUser
password project.properties.forgeMavenPassword
}
url 'http://files.minecraftforge.net/maven/manage/upload'
} else {
url 'file://' + rootProject.file('repo').getAbsolutePath()
}
}
}
}
}
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rootProject.name = 'ForgeGradle'
rootProject.name = 'ForgeGradle'
enableFeaturePreview('STABLE_PUBLISHING') //Make building shut up.

0 comments on commit 52f4e47

Please sign in to comment.