question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make Jenkins Pipelines Templates more Flexible

See original GitHub issue

Is your feature request related to a problem?

In the CodeAbility project we have many instructors that propose specific requirements on Test executions. Currently the Jenkins pipeline definition template in src/main/resources/templates/jenkins/…/JenkinsFile is very unflexible. It only allows replacement of certain dedicated variables.

However we need more flexible ways to define pipelines, e.g. if-then-else based on exercise variables.

E.g. in freemarker markup

pipeline {
        options {
            timeout(time: <#if exercise.difficulty=EASY>${jenkinsTimeout}<#else>${5*jenkinsTimeout}</#if>
        }
...
steps {
<#if exercise.categories.contain('requiresUI')>
            wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) {
</#if>
                junit ...
<#if exercise.categories.contain('requiresUI')>
        }
</#if>
        }

Describe the solution you’d like

  1. We would propose to replace the current static textual variable replacements by more flexible ways of a template generator (e.g. freemarker
  2. Provide more flexible ways to provide (Jenkins) templates. I.e. do not freeze it in the source code, but e.g. load it from a configurable URL/Filesystem/… .

Describe alternatives you’ve considered

There are not really good alternatives:

  • restrict our instructor users to the definitions available
  • manually make changes in Jenkins pipelines

Additional context

We volunteer to provide a solution above.

The change can be done in a first implementation transparent to upgrades. The resulting files will be identical between old and new generation mechanisms. On the long run, we want to implement further exercise attributes to configure the pipeline configuration.

Also flexible template generation can be applied to other templates (e.g. example generation).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Wallenstein61commented, Feb 4, 2021

Hello, just as an intermediate feedback. I have played around with your proposal. Had a hard time to get it running (not being a groovy expert).

It seemed that there was a

   return this;

missing at the end of “pipeline.groovy”. ( see https://stackoverflow.com/questions/54838794/jenkinsfile-java-lang-nullpointerexception-cannot-invoke-method-printpn-on )

The next step will be, to make it run inside our projects.

0reactions
b-feincommented, Oct 7, 2022

Closing this issue as there is now a more detailed issue (#5726) describing how the approach as proposed above could be implemented as part of a proper integration into Artemis.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing the Jenkins Templating Engine!
The Templating Engine Plugin allows you to remove the Jenkinsfile from each repository by defining a common workflow for teams to inherit.
Read more >
Managing Jenkins Pipelines. Our Continuous integration and…
We felt like Jenkins CLI was the only option flexible enough to allow for the integration later on. Pipeline Templates. To start off...
Read more >
Best Jenkins Pipeline Tutorial - Create JenkinsFile
Follow the steps in this tutorial to create your first Jenkins pipeline. Run Selenium automation in Jenkins through an online Selenium Grid.
Read more >
Jenkins Templating Engine: How To Build Reusable Pipeline ...
The Jenkins Templating Engine allows pipeline developers to create common workflows (called pipeline templates) and share them across teams.
Read more >
6 Tools for Building a Scalable Jenkins Pipeline in 2020
This automatically creates a Jenkinsfile from the linked SCM repo that simply requests a handful of parameters (outlined in the template.yaml ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found