Create a test task for jenkins builds with parameters

(michael.wagner6) #1

Hi, I am new to gradle and wondering since some ours how I can test a gradle script that is designed to run with jenkins and has parameters. I have a file upload and an option as build parameters. How can I fake this with a test file to test it from the shell? My approach:

def upload = System.getenv("upload")
def singleDelivery = System.getenv("singleDelivery")
task createDistDirectories() << {
 ext.distDir = new File(buildDir, distDirName)
 languages.each {
  ext.languageFolder = new File(buildDir, distDirName + System.getProperty("file.separator") + it)
  task deployNews(type: DeployNewsTask, dependsOn: createDistDirectories) {
 println "upload: " + upload
 println singleDelivery
 doLast {
  task testDeployNewsSingleDelivery(dependsOn: deployNews) {
 // test singleDelivery for test pdf file
 singleDelivery = true
 upload = "News_2013_1_es.pdf"
 println "variables set"
 doLast {
  assert file(distDirName).isDirectory()
  languages.each { s -> assert file(distDirName + s).isDirectory() }

But this does not work since code in testDeployNewsSingleDelivery is executed after the deployNews code. Using << for deploy news does not work either. How can I set the values in a test task for testing?

Thanks and Regards, Michael