gsaldana
gsaldana

Reputation: 449

Integrate Xebialas Deployit Plugin into jenkins DSL groovy job

I'm trying to create a "freestyle-job" from a groovy file. I already have set up a single job with compilation, unit tests and sonarqube scanner. I want to add the package generation and deployment using Xebialabs Deployit plugin but I can't find the right syntax for the step.

I tried to add this to my job. However I don't know in which section (steps, publishers, other...) I have to add it.

xld {
      deploy('app', '1.0') {
        deployable('listDirectory', 'cmd.Command') {
          commandLine = 'ls'
        }
      }
    }

Also I already have created a declarative pipeline to build my app. In this case the "pipeline syntax" tool provides you an example of how to use this plugin. This the only one approach that has worked.

This is my freestyle-job groovy file.

branch = "development"
git_url = "https://github.com/my-repo/my-app"
git_token = "GIT_TOKEN"

freeStyleJob('my-app') {
    logRotator(numToKeep = 100)
    description('Automatic compilation job')
    parameters {
        stringParam("GIT_BRANCH", "master", "Branch to build")
    }
    environmentVariables {
        env('CI_VERSION', '${BUILD_DATE_FORMATTED, "yyyyMMdd"}.${BUILDS_TODAY}')
    }
    properties {
        githubProjectUrl(git_url)
    }
    scm {
        git {
            remote {
                url(git_url)
                credentials(git_token)
            }
            branch($GIT_BRANCH)
        }
    }
    triggers{
        githubPush()
    }
    steps {
        shell('mvn clean verify sonar:sonar')
    }
    publishers {
        archiveJunit('**/target/surefire-reports/*.xml')
    }
}

Does anyone know what is the right syntax to add the DeployIt plugin into this job and in which step do I have to add it?

Upvotes: 0

Views: 70

Answers (1)

daspilker
daspilker

Reputation: 8194

The Job DSL also provides an API viewer for syntax help. See Dynamic DSL for details.

In case of the DeployIt plugin, the syntax is

job(String name) {
  publishers {
    deployitNotifier {
      credential(String value)
      application(String value)
      version(String value)
      packageOptions {
        // ...
      }
      importOptions {
        // ...
      }
      deploymentOptions {
        // ...
      }
      verbose(boolean value)
      packageProperties {
        // ...
      }
      overridingCredential {
        // ...
      }
    }
  }
} 

Upvotes: 0

Related Questions