unable to resolve class hudson.model.StringParameterValue

404 Views Asked by At

I am developing a groovy script in my pipeline A to get the latest revision of a svn repository ,save it into revision variable and append it to the version number tag in a POM file in Pipeline B. The idea is that this pipeLine A triggers pipeLine B if A is successfully run. When running the pipeLine A I get the following errors :

 1. unable to resolve class hudson.model.StringParameterValue
 2. unable to resolve class hudson.model.ParametersAction

Here is the code :

import groovy.json.*
import jenkins.model.*
import hudson.model.*
import hudson.util.*
    def revision = trunkRevision()
        def trunkRevision() {
            def ant = new AntBuilder() 
            ant.exec(executable: "svn", outputproperty: "output", dir: "."){ 
            arg(line: "info https://someURL/trunk -r HEAD")}
            svnInfo = ant.project.getProperty("output")
              def pattern = /Last\s+Changed\s+Rev:\s+(\d+)/ 
            def matcher = (svnInfo =~ pattern)
            def actualRevision =  matcher[0][1]
            def param = new hudson.model.StringParameterValue('actualRevision', actualRevision)
            def paramAction = new hudson.model.ParametersAction(param);
            def thr = Thread.currentThread();
            def currentBuild = thr?.executable;
            currentBuild.actions.add(paramAction)
            return actualRevision

What have Itried?

  1. I tried running the script in a Execute Groovy script build step , specifying the groovy version and installation
  2. I tried running the script in a Execute System Groovy script build step.
  3. I tried installing different plugins that I thought might come in handy , for example global-build-stats plugin

Ps. When I run the exact same script in a Execute System Groovy script , I get an error saying :

java.lang.IndexOutOfBoundsException: index is out of range 0..-1 (index = 0)

I don't know where I am wrong. I should also mention that everything is running on master , there's no slave in my pipeline!

0

There are 0 best solutions below