GithubHelp home page GithubHelp logo

markewaite / workflow-remote-loader-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oleg-nenashev/workflow-remote-loader-plugin

0.0 1.0 0.0 110 KB

Jenkins plugin, which allows to load Pipeline script objects from remote locations (e.g. Git)

License: MIT License

Java 66.15% Groovy 33.85%

workflow-remote-loader-plugin's Introduction

Pipeline Remote File Loader Plugin

Summary

The Pipeline: Groovy Libraries plugin replaces this plugin. The Pipeline shared libraries section of the Jenkins User Handbook describes the Pipeline: Groovy Libraries plugin in detail.

The plugin simplifies the usage of the shared functionality in Pipeline scripts. It allows Pipeline scripts to be stored in remote SCM iles and loads them on-demand.

Supported features:

  • Groovy file loading from Git and Github (requires an installed Git plugin)

Usage

The plugin adds a global fileLoader DSL variable, which provides methods for loading Pipeline objects from remote sources.

Available methods

The fileLoader variable provides the following methods:

  • fromGit(String libPath, String repository, String branch, String credentialsId, String labelExpression, boolean skipNodeCreation) - loading of a single Groovy file from the specified Git repository

  • withGit(String repository, String branch, String credentialsId, String labelExpression, boolean skipNodeCreation) - wrapper closure for multiple files loading from a same Git repo

  • fromSVN(String libPath, String repository, String credentialsId, String labelExpression, boolean skipNodeCreation) - loading of a single Groovy file from the specified SVN repository

  • withSVN(String repository, String credentialsId, String labelExpression, boolean skipNodeCreation) - wrapper closure for multiple files loading from a same SVN repo

  • load(String libPath) - loading of an object from a Groovy file specified by the relative path. Also can be used within withGit() closure to load multiple objects at once

Parameters:

  • libPath - a relative path to the file, ".groovy" extension will be added automatically
  • repository
    • for Git - string representation of a path to Git repository. Supports all formats supported by Git Plugin
    • for SVN - string representation of a path to/or inside an SVN repository.
  • branch - Optional: Branch to be used (it's also possible to specify labels). Default value: master
  • credentialsId - Optional: Credentials to be used for the Git repo checkout. Default value: null (unauthorized access)
  • labelExpression - Optional: label expression, which specifies a node to be used for checkout. Default value: empty string (runs on any node)
  • skipNodeCreation - Optional: If true the creation of a new node is skipped. Default value: false (creates a new node)

Groovy file format

The loading behaves similarly to the built-in load command, see Pipeline documentation for more info about library file syntax. Only one file is being loaded by commands from fileLoader. Use static initializers within the Groovy file of the loaded file to load more context from neighbor files.

Examples

Loading a single Groovy file from Git:

stage 'Load a file from GitHub'
def helloworld = fileLoader.fromGit('examples/fileLoader/helloworld',
        'https://github.com/jenkinsci/workflow-remote-loader-plugin.git', 'master', null, '')

stage 'Run method from the loaded file'
helloworld.printHello()

Loading multiple files from Git:

stage 'Load files from GitHub'
def environment, helloworld
fileLoader.withGit('https://github.com/jenkinsci/workflow-remote-loader-plugin.git', 'master', null, '') {
    helloworld = fileLoader.load('examples/fileLoader/helloworld');
    environment = fileLoader.load('examples/fileLoader/environment');
}

stage 'Run methods from the loaded content'
helloworld.printHello()
environment.dumpEnvVars()

License

MIT License

Changelog

GitHub releases

workflow-remote-loader-plugin's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.