[JIRA] (JENKINS-59995) Process DSL does not respect folder structure

5 views
Skip to first unread message

artalus-mail@yandex.ru (JIRA)

unread,
Oct 31, 2019, 4:29:03 AM10/31/19
to jenkinsc...@googlegroups.com
Artalus S. created an issue
 
Jenkins / Bug JENKINS-59995
Process DSL does not respect folder structure
Issue Type: Bug Bug
Assignee: Daniel Spilker
Components: job-dsl-plugin
Created: 2019-10-31 08:28
Environment: job-dsl-plugin 1.74
Priority: Major Major
Reporter: Artalus S.

1) The Process DSL steps fail at creating top-level (not in folder) items, if the deployer job itself is located inside a folder.
Example: I have a `/folder` folder in my root jobs directory, and a `/folder/deployer` job in it that creates a `/free` job. When there is no `/free`, the DSL pass finishes fine. When `/free` is already deployed via `/folder/deployer` though, redeployment will fail with `ERROR: Could not create item folder, item is already managed by seed job folder/deployer`.

Looking at `JenkinsJobManagement.java:createOrUpdateConfig`, it happens because the `seedJobName` at line 146 contains the result of `getName()` — a mere `deployer`. In the `getGeneratedJobMap()` however, the seed job is stored as fully-qualified `folder/deployer`. Thus, `seedJobName != existingSeedJobName`, which causes exception.

At first glance, the bug can be fixed by simply changing `String seedJobName` from `getName()` to `getFullName()`

2) Suppose I have two jobs that both try to create a `folder/free` job: `deployer_a` and `deployer_b`. If I run them both, they will both happily easily override each other's results, even if you specify `Fail if seed collision`.

Looking at the same source file, it happens because of `getGeneratedJobMap().get(jobName)` — with `jobName` containing a mere free due to `FilenameUtils.getName(path)` above. While there is `folder/free` entry in generated map, there is no `free` entry, so `.get()` will return null and the seeder equality check will not perform at all.

Contrary, if I use `deployer_root` to create `/free` and then `deployer_folder` to create `folder/free`, then `deployer_folder` will fail saying `Could not create item free, item is already managed by seed job deployer_root`. In this case, there will be `free` entry in map created by `deployer_root`, and `deployer_folder` will pick it up instead and fail the seeder equality check.

This can seemingly be fixed by using whole `path` in `.get()` instead of `jobName`.

Both of those bugs were found in 1.74, but I am fairly sure the issue is still present in 1.76, since no changes in that java file were made.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

mail@daniel-spilker.com (JIRA)

unread,
Mar 6, 2020, 10:05:03 AM3/6/20
to jenkinsc...@googlegroups.com
Change By: Daniel Spilker
Status: Open Fixed but Unreleased
Resolution: Fixed
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

mail@daniel-spilker.com (JIRA)

unread,
Mar 11, 2020, 9:01:03 AM3/11/20
to jenkinsc...@googlegroups.com
Change By: Daniel Spilker
Status: Fixed but Unreleased Closed
Released As: job-dsl 1.77
Reply all
Reply to author
Forward
0 new messages