How to store last value of parameter in parameterized job as a default value for next build in Jenkins?

You can add a System groovy build step to your job (or maybe a post build Groovy step) using the Jenkins API to directly modify the project setting the default parameter value.

Here is some code that may be useful to get you started:

import hudson.model.*

paramsDef = build.getParent().getProperty(ParametersDefinitionProperty.class)
if (paramsDef) {
  paramsDef.parameterDefinitions.each{ param ->
    if (param.name == 'FOO') {
      println("Changing parameter ${param.name} default value was '${param.defaultValue}' to '${param.defaultValue} BAR'")
      param.defaultValue = "${param.defaultValue} BAR"
    }
  }
}

Have a look at the class ParameterDefinition in the Jenkins model.

You probably need to modify the default param value based on the current build executing. Some code to get that would look like this:

def thisBuildParamValue = build.buildVariableResolver.resolve('FOO')

The Persistent Parameter Plugin is exactly what you are looking for!

You just need to download it from the official Jenkins repository and install it, no need for any additional setup.

Then on your job, you just need to add a "Persistent Parameter" in order to have default values used and saved between builds.