Store (small) table data in Jenkins without external database

2018-11-13 Thread Nick Mellor
Hi,

I'm building a Jenkins front-end for a small team of developers. I need to 
store name, email, permission level and one or two other bits of data per 
developer. Passwords can be handled by the credentials facility.

My employer is not AT ALL happy about spending money, so doesn't want even 
a small ongoing cost (AU$90 p.a.) from an RDS database. What's the best way 
to avoid using an external database in this situation? Potentially the data 
is only a few K long.

Obviously I could store these data in a CSV, JSON or YAML file, committed 
to an SCM, but I'd quite like to use the data in a Jenkins extensible 
choice parameter or similar if this is possible.

Thanks for any help,

Nick

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/083cec96-0bd1-4218-9e6c-9d108b7acfc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to set "Environment variables" in "Global properties" of global Jenkins configuration programmatically?

2018-08-05 Thread Nick Mellor
the problem appears to be

hudson.slaves.EnvironmentVariablesNodeProperty.class

 passed as a parameter, but which can't be serialised.

On Monday, 6 August 2018 11:24:34 UTC+10, Nick Mellor wrote:
>
> Just to be clear: I had working code in Jenkins 2.19 that looked like this:
>
> def appVersion(String app, incrementPatch = true) {
>   assert app.toLowerCase() in ['appName'], "No such project implemented: 
> '$app'"
>   def version = [
>   elms: env.VERSION_OVERRIDE,
>   lacm: env.LACM_VERSION_OVERRIDE,
>   ].get(app.toLowerCase())
>   if (!version) {
> // auto-generate version number if no manual version given
> def nodes = Jenkins.instance.globalNodeProperties
> nodes.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)
> if (nodes.size() != 1) {
>   echo "Error: unexpected number of environment variable containers: 
> ${nodes.size()} (expected 1)"
> } else {
>   def envVars = nodes[0].envVars
>   // last patch number used is maintained per major/minor version
>   // stored in e.g. 'PATCH_VERSION_17.10' in Jenkins
>   def majorMinorVersion = env.MONTHLY_RELEASE_VERSION
>   def majorMinorPatchVar = 
> "${app.toUpperCase()}_PATCH_VERSION_${majorMinorVersion}"
>   String currentPatchVersion = envVars[majorMinorPatchVar]
>   if (currentPatchVersion) {
> if (incrementPatch) {
>   currentPatchVersion = (Integer.parseInt(currentPatchVersion) + 
> 1) as String
> }
>   } else {
> currentPatchVersion = '1'
>   }
>   // NB timestamp needs to be set statically by the pipeline
>   // to maintain version parity between pipeline stages
>   def timestamp = env.BUILD_TIMESTAMP
>   version = "$majorMinorVersion.$currentPatchVersion-$timestamp"
>   // create or update auto patch version for this major/minor build
>   // this will create new variable in Jenkins if necessary
>   envVars[majorMinorPatchVar] = currentPatchVersion
>   Jenkins.instance.save()
> }
>   }
>   echo "Autogenerated ${app.toUpperCase()} version is '$version'"
>   return version
> }
>
>
>
> Have had trouble since moving to Jenkins 2.31.
>
> Hey guys, please hold the (no doubt excellent) advice to upgrade to the 
> latest Jenkins: I'm at a large corporate that doesn't (can't, won't) move 
> quickly on Jenkins version.
>
> Thanks for any input,
>
> Nick
>
> On Monday, 6 August 2018 11:17:15 UTC+10, Nick Mellor wrote:
>>
>> Hi Zilla, this doesn't work for me. I get:
>>
>> java.io.NotSerializableException: 
>> hudson.slaves.EnvironmentVariablesNodeProperty
>>
>>
>> Any ideas?
>>
>>
>> Thanks,
>>
>>
>> Nick
>>
>>
>> On Friday, 27 July 2018 01:14:23 UTC+10, ZillaYT wrote:
>>>
>>> I just had to do this to fix it.
>>>
>>> Jenkins instance = Jenkins.getInstance()
>>> def globalNodeProperties = instance.getGlobalNodeProperties()
>>> def envVarsNodePropertyList = globalNodeProperties.getAll(hudson.slaves.
>>> EnvironmentVariablesNodeProperty.class)
>>> def newEnvVarsNodeProperty = null
>>> def envVars = null
>>>
>>>
>>>
>>> On Thursday, July 26, 2018 at 10:52:49 AM UTC-4, ZillaYT wrote:
>>>>
>>>> I copy/pasted this code in my Jenkinsfile (including import calls 
>>>> above) and I get
>>>>
>>>> an exception which occurred:
>>>> in field groovy.lang.Closure.delegate
>>>> in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@4d78782
>>>> in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
>>>> in object 
>>>> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@41f97d3f
>>>> in object 
>>>> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@41f97d3f
>>>> Caused: java.io.NotSerializableException: hudson.model.Hudson
>>>> at 
>>>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
>>>> at 
>>>> org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
>>>> at 
>>>> org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
>>>> at 
>>>> org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerO

Re: How to set "Environment variables" in "Global properties" of global Jenkins configuration programmatically?

2018-08-05 Thread Nick Mellor
Just to be clear: I had working code in Jenkins 2.19 that looked like this:

def appVersion(String app, incrementPatch = true) {
  assert app.toLowerCase() in ['appName'], "No such project implemented: 
'$app'"
  def version = [
  elms: env.VERSION_OVERRIDE,
  lacm: env.LACM_VERSION_OVERRIDE,
  ].get(app.toLowerCase())
  if (!version) {
// auto-generate version number if no manual version given
def nodes = Jenkins.instance.globalNodeProperties
nodes.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class)
if (nodes.size() != 1) {
  echo "Error: unexpected number of environment variable containers: 
${nodes.size()} (expected 1)"
} else {
  def envVars = nodes[0].envVars
  // last patch number used is maintained per major/minor version
  // stored in e.g. 'PATCH_VERSION_17.10' in Jenkins
  def majorMinorVersion = env.MONTHLY_RELEASE_VERSION
  def majorMinorPatchVar = 
"${app.toUpperCase()}_PATCH_VERSION_${majorMinorVersion}"
  String currentPatchVersion = envVars[majorMinorPatchVar]
  if (currentPatchVersion) {
if (incrementPatch) {
  currentPatchVersion = (Integer.parseInt(currentPatchVersion) + 1) 
as String
}
  } else {
currentPatchVersion = '1'
  }
  // NB timestamp needs to be set statically by the pipeline
  // to maintain version parity between pipeline stages
  def timestamp = env.BUILD_TIMESTAMP
  version = "$majorMinorVersion.$currentPatchVersion-$timestamp"
  // create or update auto patch version for this major/minor build
  // this will create new variable in Jenkins if necessary
  envVars[majorMinorPatchVar] = currentPatchVersion
  Jenkins.instance.save()
}
  }
  echo "Autogenerated ${app.toUpperCase()} version is '$version'"
  return version
}



Have had trouble since moving to Jenkins 2.31.

Hey guys, please hold the (no doubt excellent) advice to upgrade to the 
latest Jenkins: I'm at a large corporate that doesn't (can't, won't) move 
quickly on Jenkins version.

Thanks for any input,

Nick

On Monday, 6 August 2018 11:17:15 UTC+10, Nick Mellor wrote:
>
> Hi Zilla, this doesn't work for me. I get:
>
> java.io.NotSerializableException: 
> hudson.slaves.EnvironmentVariablesNodeProperty
>
>
> Any ideas?
>
>
> Thanks,
>
>
> Nick
>
>
> On Friday, 27 July 2018 01:14:23 UTC+10, ZillaYT wrote:
>>
>> I just had to do this to fix it.
>>
>> Jenkins instance = Jenkins.getInstance()
>> def globalNodeProperties = instance.getGlobalNodeProperties()
>> def envVarsNodePropertyList = globalNodeProperties.getAll(hudson.slaves.
>> EnvironmentVariablesNodeProperty.class)
>> def newEnvVarsNodeProperty = null
>> def envVars = null
>>
>>
>>
>> On Thursday, July 26, 2018 at 10:52:49 AM UTC-4, ZillaYT wrote:
>>>
>>> I copy/pasted this code in my Jenkinsfile (including import calls above) 
>>> and I get
>>>
>>> an exception which occurred:
>>> in field groovy.lang.Closure.delegate
>>> in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@4d78782
>>> in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
>>> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@41f97d3f
>>> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@41f97d3f
>>> Caused: java.io.NotSerializableException: hudson.model.Hudson
>>> at 
>>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
>>> at 
>>> org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
>>> at 
>>> org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
>>> at 
>>> org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
>>> at 
>>> org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
>>> at 
>>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
>>> at 
>>> java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:333)
>>> at java.util.HashMap.writeObject(HashMap.java:1362)
>>> at sun.reflect.GeneratedMethodAccessor139.invoke(Unknown Source)
>>> at 
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:498)
>>> at 
>>> org

Re: How to set "Environment variables" in "Global properties" of global Jenkins configuration programmatically?

2018-08-05 Thread Nick Mellor
Hi Zilla, this doesn't work for me. I get:

java.io.NotSerializableException: hudson.slaves.EnvironmentVariablesNodeProperty


Any ideas?


Thanks,


Nick


On Friday, 27 July 2018 01:14:23 UTC+10, ZillaYT wrote:
>
> I just had to do this to fix it.
>
> Jenkins instance = Jenkins.getInstance()
> def globalNodeProperties = instance.getGlobalNodeProperties()
> def envVarsNodePropertyList = globalNodeProperties.getAll(hudson.slaves.
> EnvironmentVariablesNodeProperty.class)
> def newEnvVarsNodeProperty = null
> def envVars = null
>
>
>
> On Thursday, July 26, 2018 at 10:52:49 AM UTC-4, ZillaYT wrote:
>>
>> I copy/pasted this code in my Jenkinsfile (including import calls above) 
>> and I get
>>
>> an exception which occurred:
>> in field groovy.lang.Closure.delegate
>> in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@4d78782
>> in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
>> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@41f97d3f
>> in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@41f97d3f
>> Caused: java.io.NotSerializableException: hudson.model.Hudson
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
>> at 
>> org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
>> at 
>> org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
>> at 
>> org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
>> at 
>> org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
>> at 
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
>> at 
>> java.util.LinkedHashMap.internalWriteEntries(LinkedHashMap.java:333)
>> at java.util.HashMap.writeObject(HashMap.java:1362)
>> at sun.reflect.GeneratedMethodAccessor139.invoke(Unknown Source)
>> at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:498)
>> at 
>> org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:273)
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>> at 
>> org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
>> at 
>> org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
>> at 
>> org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
>> at 
>> org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
>> at 
>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
>> at 
>> com.cloudbees.groovy.cps.SerializableScript.writeObject(SerializableScript.java:26)
>> at sun.reflect.GeneratedMethodAccessor149.invoke(Unknown Source)
>> at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:498)
>> at 
>> org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:273)
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>> at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>> at org.jboss.marshalling>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/83087438-a9a9-4f2f-ab89-cb16395de10c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to diagnose java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector errors?

2017-08-21 Thread Nick Mellor
Quick finding-- these errors have generally meant some problem with my 
source code. One thing I note is that variables scoped at script level seem 
to cause this error. Wrap them in a method and the problem disappears. So 
use

def gitPipelineUser() {
   'svcx_git_user'
}

 rather than

def gitPipelineUser = 'svc_git_user' 

This is probably not the only reason you might get this error, but it's one 
possible thing to check.

Cheers,

Nick

On Friday, 7 October 2016 09:37:29 UTC+11, John Hovell wrote:
>
> Quick question how to diagnose non-serializable errors, or how to avoid 
> the issue entirely in my case.
>
> I thought I could add a @NonCPS annotation 
>  to my 
> method to bypass/disable serialization but adding the annotation does not 
> seem to make any difference in the error I receive. 
>
> Jenkins is 2.7.4 with latest plugins as of a few days ago.
>
> Am I using NonCPS incorrectly or is there a way to translate the below 
> code-snippet to something that is serializable (seems unnecessary in my 
> case but perhaps this is the only option for global libraries?)
>
> (Relatedly, would it be simpler to use a bash script to perform the below 
> logic? Is there some parallel/analog for global pipeline libraries for 
> bash? I saw there is support for resources but not files that can be 
> executed)
>
> java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.mars