Get gradle variables in jenkins pipeline script
<p>I'm trying to migrate my build pipelines to the "Pipeline plugin" using the groovy build scripts.</p>

<p>My pipelines are usually:</p>

<ol>
<li>Test (gradle)</li>
<li>IntegrationTest (gradle)</li>
<li>Build (gradle)</li>
<li>Publish (artifactory)</li>
</ol>

<p>I would like to use the gradle variables like version/group etc. in my jenkins build script to publish to the correct folders in artifactory. Something the artifactory plugin would take care of for me in the past. How can this be achieved?</p>

<p>For a single gradle project I use something like this:</p>

<pre><code>node('master')
{
    def version = 1.0
    def gitUrl = 'some.git'
    def projectRoot = ""
    def group = "dashboard/frontend/"
    def artifactName = "dashboard_ui"
    def artifactRepo = "ext-release-local"

    stage "git"

    git branch: 'develop', poll: true, url: "${gitUrl}"

    dir(projectRoot)
    {

        sh 'chmod +x gradlew'
        stage "test"
        sh './gradlew clean test'

        stage "build"
        sh './gradlew build createPom'

        stage "artifact"
        def server = Artifactory.server('artifactory_dev01')
        def uploadSpec = """{
          "files": [
            {
              "pattern": "build/**.jar",
              "target": "${artifactRepo}/$group/${artifactName}/${version}/${artifactName}-${version}.jar"
            },
            {
              "pattern": "pom.xml",
              "target": "${artifactRepo}/$group/${artifactName}/${version}/${artifactName}.pom"
            }
         ]
        }"""
        def buildInfo1 = server.upload spec: uploadSpec
        server.publishBuildInfo buildInfo1
    }
}
</code></pre>