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.

Ability to reference relative file for "jobs:" configuration

See original GitHub issue

Current jobs: looks like this:

jobs:
  - script: >
      multibranchPipelineJob('configuration-as-code') {
          branchSources {
              git {
                  id = 'configuration-as-code'
                  remote('https://github.com/jenkinsci/configuration-as-code-plugin.git')
              }
          }
      }

I would much prefer to have it reference files.

jobs:
   files:
      - job1.groovy
      - ./other/job2.groovy

I my experience, no seed job is quite as simple as the example. When attempting to migrate an existing server to JCASC one of my biggest stumbling blocks was converting/escaping/updating existing jobdsl. If jcasc supported loading of groovy files then I could almost just copy existing jobdsl and use it with almost zero effort on my part.

The advantage of this is that:

  • remove the need for any escaping
  • can use a groovy aware editor for jobdsl
  • can easily test jobdsl in Jenkins or with other tools (without need for unescape/escape cycle
  • greatly simplify migration to JCASC by allowing easy re-use of existing scripts.

Jenkins version: 2.156 Plugin version: 1.4 OS: docker:alpine

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Lorquascommented, Feb 11, 2019

try:

jobs:
  - file: /some/path/jenkins/can/get/to/file.groovy
  - file: /some/other/file.groovy

*EDIT: the file has to be avaialbe to the jenkins master, I put it in $JENKINS_HOME. You can also use - url: http://some/file.groovy. Found this by reading the source in support/src/main/java/io/jenkins/plugins/casc/support/jobdsl; This could probably be documented in the jobs section of the demos.

0reactions
EricSalemicommented, Jun 30, 2020

Seems to be documented here:

https://github.com/jenkinsci/job-dsl-plugin/wiki/JCasC

Does not work me when using the jenkins/jenkins:2.235.1 Docker image.

Apparently other people see this issue in https://github.com/jenkinsci/configuration-as-code-plugin/issues/1145#issuecomment-624077197 (closed issue)

Read more comments on GitHub >

github_iconTop Results From Across the Web

`.gitlab-ci.yml` keyword reference - GitLab Docs
Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.
Read more >
How should software tools interpret relative paths in settings ...
Our current approach is to treat relative paths as being relative to the config file. This allows users to place a config file...
Read more >
How To: Properly Use Relative Paths - Alteryx Community
The simplest way to set relative paths is to select your input/output files using absolute (full paths) file paths.
Read more >
How to Provide References With a Job Application
Employers may ask for a list of references with a job application. Here's who to use and how to provide a reference list...
Read more >
How To Create A Relative File Path In Power Query - Excel TV
Right click on the bottom of the worksheet and add a new tab. I recommend calling it Setup but you can also call...
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