Make pipeline loader more flexible

Description

The pipeline loader, used to load pipeline scripts from the Jenkins repo is missing a couple of useful features:

  1. It takes on a node and keeps it. If the pipelines are long, the node is kept for the whole time even if its not used. It would be a useful optimization to let pipeline scripts specify code that runs without the node.

  2. It is impossible to access functions that are defined in the loader from the pipeline scripts.

The following solution is offered to provide both features:

We will change the loader to look for a "loader_main" function in the pipeline script. If it exists it will call it passing itself as an argument. This way that function will get access to function in the loader and can store them for use by other functions.

If a "main" function exists in the pipeline script in addition to the "loader_main" function, if will be called outside of the "node" block in the loader. This way we can run code in "main" that does not need the loader node.

If a "loader_main" function will not exist in a pipeline, the "main" function will be called from inside the "node" block, like it is today. This way we maintain compatibility with existing pipeline scripts.

Activity

Show:

Barak Korren June 14, 2017 at 12:53 PM

patch merged.

Barak Korren May 29, 2017 at 11:42 AM

Original patch was merged, but an additional fix patch was needed and still pending review.

Barak Korren May 23, 2017 at 9:18 PM

Created a patch.

Blocking on review.

Fixed

Details

Assignee

Reporter

Blocked By

Components

Priority

Created May 23, 2017 at 4:20 PM
Updated July 2, 2017 at 2:08 PM
Resolved June 14, 2017 at 12:53 PM

Flag notifications