Skip to content

Commit

Permalink
Modified gradle to support passing credentials from Jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
szydan committed Dec 8, 2017
1 parent a220359 commit 59c6e03
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
/.idea
/target
/build
package-lock.json
17 changes: 3 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,11 @@ apply plugin: 'com.moowork.grunt'
apply plugin: 'com.moowork.node'
apply plugin: 'org.ajoberstar.grgit'
apply plugin: 'maven-publish'
apply from: "$rootDir/gradle/utils/repository.gradle"
apply from: "$rootDir/gradle/utils/loadPackageJson.gradle"

import groovy.json.JsonSlurper
import org.ajoberstar.grgit.Grgit

///////////////////////////////////////////////////
// //
// Package Json //
// //
///////////////////////////////////////////////////

def loadPackageJson() {
File packageJson = new File(projectDir, "package.json")
return new JsonSlurper().parseText(packageJson.text)
}

def packageJson = loadPackageJson()

///////////////////////////////////////////////////
Expand Down Expand Up @@ -259,15 +249,14 @@ clean.dependsOn 'gulp_clean'
///////////////////////////////////////////////////

publishing {
repositories getArtifactoryRepository()
publications {

zipDist(MavenPublication) {
artifact(new File("${projectDir}/target/gulp", "${packageJson.name}.zip"))
groupId project.group
artifactId "sentinl"
version packageJson.version
}

}
}

7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
nodeVersion=6.9.0

# placeholders needed so gradle will not complain about missing properties during init phase
# these are provided by Jenkins
artifactory_username=
artifactory_password=
artifactory_url=

14 changes: 14 additions & 0 deletions gradle/utils/loadPackageJson.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Required for the loadPackageJson method
*/
apply plugin: 'groovy'
import groovy.json.JsonSlurper

def loadPackageJson() {
File packageJson = new File(projectDir, "package.json")
return new JsonSlurper().parseText(packageJson.text)
}

project.ext {
loadPackageJson = this.&loadPackageJson
}
15 changes: 15 additions & 0 deletions gradle/utils/repository.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def getArtifactoryRepository() {
return {
maven {
url project.artifactory_url + "/" + (project.version.contains('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local')
credentials {
username project.artifactory_username
password project.artifactory_password
}
}
}
}

project.ext {
getArtifactoryRepository = this.&getArtifactoryRepository
}

0 comments on commit 59c6e03

Please sign in to comment.