This is a Groovy shared lib for Jenkins 2 pipelines, but also useable as a Groovy command-line script.
It lets you interact with Hesperides to perform various tasks:
- platform and module creation
- module release
- update of platform version / modules versions
- update of properties per platform/instance of a platform/module of a platform from a JSON file
In "Manage Jenkins > Configure System" aka /jenkins/configure
, adds the git@...
URL to this repo in Global Pipeline Libraries, and ticks the "load implicitly" checkbox. You can use either the master
branch to use the latest version, or specify a tag to ensure more stability.
You will also need to install the http_request Jenkins plugin from its .hpi.
cf. examples/Jenkinsfile & vars/*.txt
documentation files for examples.
Note: to check your Jenkinsfiles syntax, use a linter ! cf. https://github.com/Lucas-C/pre-commit-hooks#other-useful-local-hooks
@GrabResolver(name='nexus', root='http://nexus.mycompany.com/content/repositories/jenkins-ci/repo.jenkins-ci.org/public')
@Grab(group='com.cloudbees', module='groovy-cps', version='1.12')
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.2')
import static groovy.json.JsonOutput.*
import com.vsct.dt.hesperides.jenkins.pipelines.Hesperides
import com.vsct.dt.hesperides.jenkins.pipelines.http.HTTPBuilderRequester
def cli = new CliBuilder()
cli.apiRootUrl(args:1, argName:'endpoint', 'Default: https://hesperides.mycompany.com')
cli.auth(args:1, required:true, argName:'auth', 'user:password')
cli.app(args:1, required:true, argName:'trigram', '')
cli.platform(args:1, required:true, argName:'instance', '')
def options = cli.parse(args)
if (options) {
def hesperides = new Hesperides(apiRootUrl: options.apiRootUrl, auth: options.auth, httpRequester: new HTTPBuilderRequester())
def platformInfo = hesperides.getPlatformInfo(app: options.app, platform: options.platform)
System.out.println prettyPrint(toJson(platformInfo))
}
cf. CONTIBUTING.md