Project

General

Profile

task #9513

Updated by Andreas Kohlbecker about 3 years ago

Due to the "table to div regression" the [Configure UI is completely broken after upgrade to 2.264](https://issues.jenkins.io/browse/JENKINS-64072) for jobs which are making use of the [scriptler plugin](https://plugins.jenkins.io/scriptler/). This incident has been reported as [JENKINS-65030](https://issues.jenkins.io/browse/JENKINS-65030). 

 ## affected jobs 

 ### edit-int 

 * cdm-vaadin-HFX-START [✓] 
 * cdm-vaadin-DEPLOY [✓] 
 * ~~taxeditor-SITE-DEPLOY~~ dynamic parameter scriptler already replaced by **git-parameter** 
 * cdm-server-HFX-START [✓] 
 * cdm-vaadin-RLS-FINISH [✓] 
 * cdm-server-RLS-FINISH [✓] 
 * taxeditor-PROVISION [✓] 
 * taxeditor-RLS-FINISH [✓] 
 * taxeditor-HFX-START [✓] 
 * cdm-vaadin-HFX-FINISH - dynamic parameter with scriptler [✓] but `ScriptlerBuilder` still **TODO**, see below 
 * cdm-dataportal-RLS-FINISH [✓] 
 * cdmlib-HFX-FINISH [✓] 
 * cdm-webapp-HFX-START [✓] 
 * taxeditor-RLS-START [✓] 
 * taxeditor-HFX-FINISH [✓] 
 * cdmlib-RLS-FINISH [✓] 
 * cdm-webapp-RLS-FINISH [✓] 
 * cdm-webapp-HFX-FINISH [✓] 
 * cdm-server-HFX-FINISH [✓] 

 **TODO** in the belos jobs here `org.jenkinsci.plugins.scriptler.builder.ScriptlerBuilder` is being used to read for example the `cdmlib.version` from the pom.xml and to store it in the `${WORKSPACE}/env.properties` which is read and injected as env variable in the next step. 

 
 * cdm-vaadin-HFX-FINISH  
 cdm-dataportal-RLS-FINISH [✓] 
 * cdm-vaadin-RLS-START cdmlib-HFX-FINISH [✓] 
 * cdm-vaadin-HFX-FINISH cdm-webapp-HFX-START [✓] 
 * cdm-webapp-RLS-START taxeditor-RLS-START [✓] 
 * cdm-server-INTEGRATION 



 taxeditor-HFX-FINISH [✓] 
 * cdmlib-RLS-FINISH [✓] 
 * cdm-webapp-RLS-FINISH [✓] 
 * cdm-webapp-HFX-FINISH [✓] 
 * cdm-server-HFX-FINISH [✓] 


 ## Solution: 

 1. downgrade jenkins to version 2.263 - not easy, see #note-2 
 2. replace scripter +    dynamic parameter plugins by something else. The scripter plugin has security issues and the maintained is searching for someone to adopt the plugin. 
     * the *dynamic parameter* may be replaced by the [extended choice parameter](https://plugins.jenkins.io/extended-choice-parameter/) plugin which also can run groovy scripts to provide the parameter list: https://stackoverflow.com/questions/24730186/jenkins-extended-parameter-plugin-groovy-script  

 ## existing groovy scripts 

 edit-int: 

 * getXPathSingleValue: used to read the maven version from the pom.xml, see https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#code-readmavenpom-code-read-a-maven-project-file for alternatives --> can be replaced by [extended-choice-parameter](https://plugins.jenkins.io/extended-choice-parameter/) which also can make use of scriptler scripts. The scriptler management UI is also broken due to the "table to divs regression", therefore it seems better to simply manage the groovy scripts in a git repository.   
 * Git Refs Lookup: was only used in unused jobs `taxeditor-SNAPSHOT`, `taxeditor-JRE-SNAPSHOT` -> jobs deleted now! 
 * Git Tag Lookup --> can be 90% replaced by [git-parameter](https://plugins.jenkins.io/git-parameter/). Limitation, the tags can only be filtered by [git-show-ref patterns](https://git-scm.com/docs/git-show-ref) so more tags will be shown. This can be improved by renaming existing tags. 
 * GIT Branch Lookup --> can be 100% replaced by [git-parameter](https://plugins.jenkins.io/git-parameter/)  


 edit-jobber: 

 * cdmserver-find-last-instance: Finds the last instance in a cdmserver 
 * cdmserver-index-job: Triggers and monitors an index or purge job on a cdmserver for a specific instance 
 * cdmserver-instance-action: Allows stopping and starting a cdmserver instance. 
 * cdmserver-monitor-instance-status: monitors the cdmsever until the specified instace shows as specific status or if the timeout is exceeded. Returns true (success) if no instances are configured. If no status is given the script will use 'started' as default. 
 * cdmserver-monitor-instance-up: monitors the cdmsever until the specified instace is started up or if the timeout is exceeded. Returns true (success) if no instances are configured. 
 * cdmserver-monitor-up: monitor cdmsever for all instaces started up. Returns true (success) if no instances are configured. 
 * filtered-cdmserver-instance-names:  
	 list datasource bean names in datasources.xml as whitespace separated text (suitable for dynamic axix), the instance names listed in the filter_str are either used as include ot exclude filter depending on the value of the filter_includes parameter. If the propertiesFile parameter is specified the final instance names will be written into the property key: 'INSTANCE_NAMES'. WRNING!!! You need to use the absolute path of the file!!!! 
 * list-maven-version: Returns a list of all available versions of an e-taxonomy.eu artifact in the wp5.e-taxonomy.eu maven repository 


 ## plugins and options to replace existing scriptler groovy scripts: 

 * https://stackoverflow.com/questions/9893503/getting-project-version-from-maven-pom-in-jenkins#22016841 

 ### [git-parameter](https://plugins.jenkins.io/git-parameter/) 

 xml config snippets 

 replace `GIT Branch Lookup` 

 ~~~xml 
 <net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition plugin="git-parameter@0.9.13"> 
     <name>BRANCH</name> 
     <uuid>ef8737cf-24cd-47f2-9388-17f7ae481dc4</uuid> 
     <type>PT_BRANCH</type> 
     <branch/> 
     <tagFilter>*</tagFilter> 
     <branchFilter>origin/hotfix/.*</branchFilter> 
     <sortMode>DESCENDING_SMART</sortMode> 
     <defaultValue>origin/master</defaultValue> 
     <selectedValue>TOP</selectedValue> 
     <quickFilterEnabled>true</quickFilterEnabled> 
     <listSize>5</listSize> 
 </net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition> 

 ~~~ 

 replace `Git Tag Lookup` 

 ~~~xml 
 <net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition plugin="git-parameter@0.9.13"> 
           <name>RELEASE_TAG</name> 
           <uuid>58781131-e61b-434d-9f52-42c3b89089a2</uuid> 
           <type>PT_TAG</type> 
           <branch/> 
           <tagFilter>*</tagFilter> 
           <branchFilter>.*</branchFilter> 
           <sortMode>DESCENDING_SMART</sortMode> 
           <defaultValue>origin/master</defaultValue> 
           <selectedValue>TOP</selectedValue> 
           <quickFilterEnabled>true</quickFilterEnabled> 
           <listSize>5</listSize> 
         </net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition> 
 ~~~ 

 ### [extended-choice-parameter](https://plugins.jenkins.io/extended-choice-parameter/) 

 **NOTE**: 

 * The script files must be located in the JENKINS_HOME folder (`/var/lib/jenkins`) otherwise they are silently ignored. 
 * Modified scripts need to be approved: https://www.jenkins.io/doc/book/managing/script-approval/ 


 **Problems** 
 
 * I could not figure out how to print log entries. `println ""` does not work as expected.   

 for how to use groovy scripts, see https://stackoverflow.com/questions/24730186/jenkins-extended-parameter-plugin-groovy-script#24731061 

 ![](picture324-1.png) 

 according xml snippet: 


 ~~~xml 
 <com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition plugin="extended-choice-parameter@0.82"> 
     <name>GIT_BRANCH_GROOVY</name> 
     <quoteValue>false</quoteValue> 
     <saveJSONParameterToFile>false</saveJSONParameterToFile> 
     <visibleItemCount>5</visibleItemCount> 
     <type>PT_SINGLE_SELECT</type> 
     <groovyScriptFile>/var/lib/jenkins/tmp-groovy-scripts/git-branch-lookup.groovy</groovyScriptFile> 
     <bindings>project=taxeditor 
 branch_prefix=hotfix 
 version_regex=.* 
 add_default_option= 
     </bindings> 
     <groovyClasspath/> 
     <multiSelectDelimiter>,</multiSelectDelimiter> 
     <projectName>Tables to divs regression</projectName> 
 </com.cwctravel.hudson.plugins.extended__choice__parameter.ExtendedChoiceParameterDefinition> 
 ~~~ 


 ### [groovy](https://plugins.jenkins.io/groovy/) plugin 

 provides build steps to execute *groovy scripts* and *script files* either as *isolated* or *system* Groovy script  

 **Differences Groovy script vs. system Groovy script** 

 * A Groovy System Script is run inside the master's JVM, that is imports like `import hudson.model.*;` can be directly be used. For *isolated* Groovy scripts you do need to add the jenkins-core jar to your classpath, and the stapler jar too. 
 * Working directory 
     * Groovy Script working directory `$WORKSPACE` 
     * system Groovy Script working directory `/` 

Back