Trouble importing from Jcenter Running From Jenkins


(Forrest Richardson) #1

Hi I am brand new to Gradle , I am trying to run build.gradle with Jenkins but am having trouble Importing from apache and groovy. Seems like all the imports fail not just one.

I am using the jcenter repository and tried both the http and https locations. I attached the build.gradle and console output from Jenkins build. I was thinking it was maybe an issue with jcenter or ports being blocked on my server but I have pretty much ruled that out. Any advice on troubleshooting?

`FAILURE: Build failed with an exception.

  • Where:
    Build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’ line: 26

  • What went wrong:
    Could not compile build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’.

startup failed:
build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 26: unable to resolve class org.apache.commons.codec.binary.Base64
@ line 26, column 1.
import org.apache.commons.codec.binary.Base64
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 23: unable to resolve class org.apache.http.HttpResponse
@ line 23, column 1.
import org.apache.http.HttpResponse
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 14: unable to resolve class groovyx.net.http.RESTClient
@ line 14, column 1.
import groovyx.net.http.RESTClient
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 21: unable to resolve class org.apache.http.protocol.HttpContext
@ line 21, column 1.
import org.apache.http.protocol.HttpContext
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 15: unable to resolve class groovyx.net.http.HTTPBuilder
@ line 15, column 1.
import groovyx.net.http.HTTPBuilder
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 20: unable to resolve class org.apache.http.HttpRequestInterceptor
@ line 20, column 1.
import org.apache.http.HttpRequestInterceptor
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 16: unable to resolve class groovyx.net.http.EncoderRegistry
@ line 16, column 1.
import groovyx.net.http.EncoderRegistry
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 22: unable to resolve class org.apache.http.HttpRequest
@ line 22, column 1.
import org.apache.http.HttpRequest
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 19: unable to resolve class org.apache.http.client.methods.HttpGet
@ line 19, column 1.
import org.apache.http.client.methods.HttpGet
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 17: unable to resolve class groovyx.net.http.ContentType
@ line 17, column 1.
import static groovyx.net.http.ContentType.TEXT
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 18: unable to resolve class groovyx.net.http.ContentType
@ line 18, column 1.
import static groovyx.net.http.ContentType.URLENC
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 40: unable to resolve class org.apache.http.HttpRequestInterceptor
@ line 40, column 74.
(new HttpRequestInterceptor() {
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 41: unable to resolve class org.apache.http.HttpRequest
@ line 41, column 20.
void process(HttpRequest httpRequest, HttpContext httpContext) {
^

build file ‘/var/lib/jenkins/workspace/ApplicationTest/build.gradle’: 41: unable to resolve class org.apache.http.protocol.HttpContext
@ line 41, column 45.
cess(HttpRequest httpRequest, HttpContex
^

14 errors

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 17.323 secs
Build step ‘Invoke Gradle script’ changed build result to FAILURE
Build step ‘Invoke Gradle script’ marked build as failure
Recording test results
ERROR: Step ‘Publish JUnit test result report’ failed: No test report files were found. Configuration error?
Finished: FAILURE`

Build.Gradle
`buildscript {
repositories {
jcenter()
}
dependencies {
classpath ‘org.codehaus.groovy.modules.http-builder:http-builder:0.7.2’
}
}

import groovyx.net.http.RESTClient
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.EncoderRegistry
import static groovyx.net.http.ContentType.TEXT
import static groovyx.net.http.ContentType.URLENC
import org.apache.http.client.methods.HttpGet
import org.apache.http.HttpRequestInterceptor
import org.apache.http.protocol.HttpContext
import org.apache.http.HttpRequest
import org.apache.http.HttpResponse
import javax.xml.transform.*
import javax.xml.transform.stream.*
import org.apache.commons.codec.binary.Base64

task runApplicationTest << {
// Define appianPasswordEncoded in gradle.properties
// as a base64-encoded string
def appianPassword = new String(appianPasswordEncoded.decodeBase64())
// The URL passed in by Jenkins
def baseURL = “$siteUrl”

def startAppURL = "/suite/webapi/startRuleTestsApplications"
def testStatusURL = "/suite/webapi/testRunStatusForId"
def fetchTestResultsURL =  "/suite/webapi/testRunResultForId"

def restClient = new RESTClient(baseURL)
restClient.client.addRequestInterceptor(new HttpRequestInterceptor() {
  void process(HttpRequest httpRequest, HttpContext httpContext) {
    httpRequest.addHeader('Authorization',
        'Basic ' + (appianUserName + ':'
+appianPassword).bytes.encodeBase64().toString())
  }
})


// *** Start Application Test ***
println "Start System Test"
def response = restClient.post(path: startAppURL)

if (response.status == 200) {
  def testRunId = response.data.text
  println "Test-run ID: " + testRunId

  //*** Check test run status every minute ***
  while(restClient.get(path: testStatusURL, query: [id:testRunId]).data.text == 'IN PROGRESS') {
    sleep(60000)
    println "Waiting for test results..."
  }

  // Fetch test results
  response = restClient.get(path: fetchTestResultsURL, query: [id: testRunId])
  def testRunResults = response.data.text

  //get a reference to our xslt
  def xslt= file("convertToJunit.xsl").text

 // Create transformer
  def transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(xslt)))

  // Set output file
  def finalXML = new FileOutputStream("testResult" + System.currentTimeMillis() + ".xml")

  // Perform transformation
  transformer.transform(new StreamSource(new StringReader(testRunResults)), new StreamResult(finalXML))
}
println "System Test Completed"

}`