Q:

jenkins - version placeholder from previous build POM

once created a job in jenkins, I want to create a parametrized build. One of the parameters is version, which I set manually. But before I set it I want to see project version from POM from last successful build as placeholder.
something like:

next version:
$PREVIOUS_VERSION_AS_PLACEHOLDER
set up next version

A:

You can add a system groovy script that would change the default value of your parameter on each run. for example:
(assuming your parameter name is "PREVIOUS_VERSION_AS_PLACEHOLDER")
import hudson.model.*
import jenkins.model.*

def job = build.getParent() // get the job object
paramsDef = job.getProperty(ParametersDefinitionProperty.class) // get the parameters definition object
if (paramsDef) {
        paramsDef.parameterDefinitions.each { param ->
            if ("PREVIOUS_VERSION_AS_PLACEHOLDER".equals(param.name)) {
                def value = <the_new_version_in_the_pom.xml_file>
                println("INFO: Changing parameter ${param.name} default value (was ${param.defaultValue}) to ${value}")
                param.defaultValue = value
            }
        }
    }

