[JIRA] (JENKINS-61956) ItemGroupMixin#createProject() does not call Jenkins#checkGoodName()

2020-05-05 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park updated an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-61956  
 
 
  ItemGroupMixin#createProject() does not call Jenkins#checkGoodName()   
 

  
 
 
 
 

 
Change By: 
 Calvin Park  
 
 
Summary: 
 ItemGroupMixin#createProject() does not call Jenkins#checkGoodName ()  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.205840.1587161495000.22374.1588722780191%40Atlassian.JIRA.


[JIRA] (JENKINS-61956) ItemGroupMixin#createProject() does not call Jenkins#checkGoodName

2020-04-29 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ItemGroupMixin#createProject() does not call Jenkins#checkGoodName   
 

  
 
 
 
 

 
 Ah sorry, I didn't realize the name itself was clickable. Thank you!  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.205840.1587161495000.19731.1588199220140%40Atlassian.JIRA.


[JIRA] (JENKINS-61956) ItemGroupMixing#createProject() does not call Jenkins#checkGoodName

2020-04-29 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ItemGroupMixing#createProject() does not call Jenkins#checkGoodName   
 

  
 
 
 
 

 
 Daniel Beck Please change the title of this ticket to ItemGroupMixin#createProject() does not call Jenkins#checkGoodName  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.205840.1587161495000.19660.1588188840051%40Atlassian.JIRA.


[JIRA] (JENKINS-61956) ItemGroupMixing#createProject() does not call Jenkins#checkGoodName

2020-04-24 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park updated an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-61956  
 
 
  ItemGroupMixing#createProject() does not call Jenkins#checkGoodName   
 

  
 
 
 
 

 
Change By: 
 Calvin Park  
 
 
Comment: 
 I've tried to contribute to the {{cloudbees-folder-plugin}} git repo but {{mvn hpi:run}} fails.{code:java}cloudbees-folder-plugin master$ mvn hpi:run[INFO] Scanning for projects...[INFO] [INFO] --< org.jenkins-ci.plugins:cloudbees-folder >---[INFO] Building Folders Plugin 6.13-SNAPSHOT[INFO] [ hpi ]-[INFO] [INFO] >>> maven-hpi-plugin:3.10:run (default-cli) > compile @ cloudbees-folder >>>[...][INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ cloudbees-folder ---[INFO] Changes detected - recompiling the module![INFO] Compiling 45 source files to /Users/calvin/GitRepos/cloudbees-folder-plugin/target/classes[INFO] -[ERROR] COMPILATION ERROR : [INFO] -[ERROR] java.nio.file.NoSuchFileException: /Users/calvin/GitRepos/cloudbees-folder-plugin/target/classes/META-INF/annotations/hudson.Extension[INFO] 1 error[...]{code}The github page didn't enable {{Issues}} feature so I can't ask for help there [https://github.com/jenkinsci/cloudbees-folder-plugin]Any ideas on how to fix the compilation error?Thank you  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
  

[JIRA] (JENKINS-61956) ItemGroupMixing#createProject() does not call Jenkins#checkGoodName

2020-04-22 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ItemGroupMixing#createProject() does not call Jenkins#checkGoodName   
 

  
 
 
 
 

 
 Opened https://github.com/jenkinsci/jenkins/pull/4684  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.205840.1587161495000.16081.1587585120058%40Atlassian.JIRA.


[JIRA] (JENKINS-61956) ItemGroupMixing#createProject() does not call Jenkins#checkGoodName

2020-04-21 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ItemGroupMixing#createProject() does not call Jenkins#checkGoodName   
 

  
 
 
 
 

 
 I've tried to contribute to the cloudbees-folder-plugin git repo but mvn hpi:run fails. 

 

cloudbees-folder-plugin master$ mvn hpi:run
[INFO] Scanning for projects...
[INFO] 
[INFO] --< org.jenkins-ci.plugins:cloudbees-folder >---
[INFO] Building Folders Plugin 6.13-SNAPSHOT
[INFO] [ hpi ]-
[INFO] 
[INFO] >>> maven-hpi-plugin:3.10:run (default-cli) > compile @ cloudbees-folder >>>
[...]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ cloudbees-folder ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 45 source files to /Users/calvin/GitRepos/cloudbees-folder-plugin/target/classes
[INFO] -
[ERROR] COMPILATION ERROR : 
[INFO] -
[ERROR] java.nio.file.NoSuchFileException: /Users/calvin/GitRepos/cloudbees-folder-plugin/target/classes/META-INF/annotations/hudson.Extension
[INFO] 1 error
[...] 

 The github page didn't enable Issues feature so I can't ask for help there https://github.com/jenkinsci/cloudbees-folder-plugin Any ideas on how to fix the compilation error? Thank you  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

 

[JIRA] (JENKINS-61956) ItemGroupMixing#createProject() does not call Jenkins#checkGoodName

2020-04-20 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ItemGroupMixing#createProject() does not call Jenkins#checkGoodName   
 

  
 
 
 
 

 
 Looked into it more and came up with this. 

 

// Create a folder and its parent folders
// mkdir -p folder_path
Folder create_folder_and_parent_folders(String folder_path) {
// If the folder already exists, return
Folder folder = Jenkins.instance.getItemByFullName(folder_path)
if (folder)
return folder

String folder_name, parent_path
def parent_folder

// If the folder is top level, set parent to Jenkins itself
if (!folder_path.contains("/")) {
parent_folder = Jenkins.instance
folder_name = folder_path
}
// If the folder is a sub-folder, recurse to create/fetch the parent folder
else {
parent_path = StringUtils.substringBeforeLast(folder_path, "/")
parent_folder = create_folder_and_parent_folders(parent_path)
folder_name = StringUtils.substringAfterLast(folder_path, "/")
}

// Create the folder in the parent folder
return parent_folder.createProject(Folder.class, folder_name)
}  

  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails 

[JIRA] (JENKINS-61956) ItemGroupMixing#createProject() does not call Jenkins#checkGoodName

2020-04-18 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ItemGroupMixing#createProject() does not call Jenkins#checkGoodName   
 

  
 
 
 
 

 
 and no insults please. I'm trying to improve Jenkins with my limited knowledge.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.205840.1587161495000.13695.1587251820178%40Atlassian.JIRA.


[JIRA] (JENKINS-61956) ItemGroupMixing#createProject() does not call Jenkins#checkGoodName

2020-04-18 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: ItemGroupMixing#createProject() does not call Jenkins#checkGoodName   
 

  
 
 
 
 

 
 This is what I've got so far - far from a 5 line function. I'd appreciate your comments on how I can improve it 

 

#jinja2: lstrip_blocks: True
#!/usr/bin/env groovy
import com.cloudbees.hudson.plugins.folder.Folder
import org.apache.commons.lang3.StringUtils;

// Create a folder in a parent folder
Folder create_folder(def parent_folder, String folder_name) {
// Actual create method call
parent_folder.createProject(Folder.class, folder_name)

// Below is unfortunately needed because createProject() doesn't return the
// newly created folder. Therefore need to query the full path again to fetch.
Jenkins jenkins = Jenkins.instance
String folder_path
if (parent_folder == jenkins) {
folder_path = folder_name
} else {
folder_path = parent_folder.fullName + "/" + folder_name
}

return jenkins.getItemByFullName(folder_path)
}

// Create a folder and its parent folders
Folder create_folder_recursively(String folder_path) {
// If the folder already exists, return
Folder jenkins_folder = Jenkins.instance.getItemByFullName(folder_path)
if (jenkins_folder)
return jenkins_folder

String folder_name, parent_path
def parent_folder

// If the folder is top level, set parent to Jenkins itself
if (!folder_path.contains("/")) {
parent_folder = Jenkins.instance
folder_name = folder_path
}
// If the folder is a sub-folder, recurse to create/fetch the parent folder
else {
folder_name = StringUtils.substringAfterLast(folder_path, "/")
parent_path = StringUtils.substringBeforeLast(folder_path, "/")

parent_folder = create_folder_recursively(parent_path)
}

// Create the folder in the parent folder
return create_folder(parent_folder, folder_name)
}

// Collect the names of all jobs and credentials
ArrayList names = new ArrayList();
{% for pipeline in pipelines %}
names.add("{{ pipeline.name }}")
{% endfor %}
{% for cred in credential_store %}
names.add("{{ cred.id }}")
{% endfor %}

// Filter to collect the names of all folders
ArrayList folders = new ArrayList();
for (String name : names) {
if (name.contains("/")) {
folders.add(StringUtils.substringBeforeLast(name, "/"))
}
}

// Remove duplicates
folders.unique().sort()

// Create folders and sub-folders
for (String folder_path : folders)
create_folder_recursively(folder_path)

 

  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
  

[JIRA] (JENKINS-61956) createProject() and getItemsByFullName() handle nested folders inconsistently

2020-04-17 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: createProject() and getItemsByFullName() handle nested folders inconsistently   
 

  
 
 
 
 

 
 Thank you for checking. Thoughts on making createProject handle subfolders?  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.205840.1587161495000.13478.1587166740125%40Atlassian.JIRA.


[JIRA] (JENKINS-61956) createProject() and getItemsByFullName() handle nested folders inconsistently

2020-04-17 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park commented on  JENKINS-61956  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
  Re: createProject() and getItemsByFullName() handle nested folders inconsistently   
 

  
 
 
 
 

 
 Is this a regression? Our folder creation script had been working for a few years and now it fails with this problem. I'm not sure what changed since we rarely upgrade master  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
 
 

 
   
 

  
 

  
 

   





-- 
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-issues/JIRA.205840.1587161495000.13422.1587164220189%40Atlassian.JIRA.


[JIRA] (JENKINS-61956) createProject() and getItemsByFullName() handle nested folders inconsistently

2020-04-17 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park updated an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-61956  
 
 
  createProject() and getItemsByFullName() handle nested folders inconsistently   
 

  
 
 
 
 

 
Change By: 
 Calvin Park  
 

  
 
 
 
 

 
 {code:java}String nested = "one/two"// Creates a single folder named "one/two" with / embedded in the namecreateProject(Folder.class, nested)// Looks for a subfolder named "two" inside a folder named "one"getItemByFullName(nested){code}As a result, this code fails{code:java}import com.cloudbees.hudson.plugins.folder.FolderString folder = "nested/folders"create_folder_if_missing(folder)create_folder_if_missing(folder)void create_folder_if_missing(String folder) {  def item = Jenkins.instance.getItemByFullName(folder)  if (item == null) {println(folder + " not found. Creating.")Jenkins.instance.createProject(Folder.class, folder)println("Created " + folder)  }  else {println(folder + " found. Skipping.")  }}{code}with the result{code:java}nested/folders not found. Creating.Created nested/foldersnested/folders not found. Creating.java.lang.IllegalArgumentException: nested/folders already exists at hudson.model.Items.verifyItemDoesNotAlreadyExist(Items.java:641){code}I think {{createProject(Folder.class, nested)}} should change its behavior to look for slashes and create subfolders, rather than allowing a slash in a folder name.  At this point it's impossible to search for a folder with a slash in the name using {{getItemByFullName()}} function.  
 

  
 
 
 
 

 
 
 

 
 
 Add Comment  
 

  
 

  
 
 
 
  
 

  
 
 
 
 

 
 This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)  
   

[JIRA] (JENKINS-61956) createProject() and getItemsByFullName() handle nested folders inconsistently

2020-04-17 Thread calvinsp...@gmail.com (JIRA)
Title: Message Title


 
 
 
 

 
 
 

 
   
 Calvin Park created an issue  
 

  
 
 
 
 

 
 
  
 
 
 
 

 
 Jenkins /  JENKINS-61956  
 
 
  createProject() and getItemsByFullName() handle nested folders inconsistently   
 

  
 
 
 
 

 
Issue Type: 
  Bug  
 
 
Assignee: 
 Unassigned  
 
 
Components: 
 core  
 
 
Created: 
 2020-04-17 22:11  
 
 
Environment: 
 Jenkins 2.164.2  Folders plugin 6.9  
 
 
Priority: 
  Minor  
 
 
Reporter: 
 Calvin Park  
 

  
 
 
 
 

 
 

 

String nested = "one/two"

// Creates a single folder named "one/two" with / embedded in the name
createProject(Folder.class, nested)

// Looks for a subfolder named "two" inside a folder named "one"
getItemByFullName(nested)
 

 As a result, this code fails 

 

import com.cloudbees.hudson.plugins.folder.Folder

String folder = "nested/folders"

create_folder_if_missing(folder)
create_folder_if_missing(folder)

void create_folder_if_missing(String folder) {
  def item = Jenkins.instance.getItemByFullName(folder)

  if (item == null) {
println(folder + " not found. Creating.")
Jenkins.instance.createProject(Folder.class, folder)
println("Created " + folder)
  }
  else {
println(folder + " found. Skipping.")
  }
}
 

 with the result