Skip to content

Instantly share code, notes, and snippets.

@yasassri
Created May 20, 2019 13:39
Show Gist options
  • Save yasassri/89531c1f7678687ab68e0fe0f924cf14 to your computer and use it in GitHub Desktop.
Save yasassri/89531c1f7678687ab68e0fe0f924cf14 to your computer and use it in GitHub Desktop.
import org.jenkinsci.plugins.envinject.EnvInjectJobProperty
import org.jenkinsci.plugins.envinject.EnvInjectJobPropertyInfo
node('master') {
script {
echo 'Hello World'
echo "$JOB_NAME"
echo "$perform"
persistInfo();
}
}
def persistInfo(){
def jenkins = Jenkins.instance
def jobA = jenkins.getItemByFullName("$JOB_NAME")
def prop2 = jobA.getProperty(org.jenkinsci.plugins.envinject.EnvInjectJobProperty);
def con = prop2.getInfo().getPropertiesContent();
def orig = []
def str = ""
for(e in con.split(System.getProperty("line.separator"))) {
if (!e.contains("UPDATED_DOCKER_IMAGES")) {
str = str + e + System.getProperty("line.separator")
}
}
str = str + "UPDATED_DOCKER_IMAGES=wso2apim-2.6.0"
def prop = new EnvInjectJobPropertyInfo("", str , "", "", "", false)
def propNew = new org.jenkinsci.plugins.envinject.EnvInjectJobProperty(prop)
propNew.setOn(true)
propNew.setKeepBuildVariables(true)
propNew.setKeepJenkinsSystemVariables(true)
jobA.addProperty(propNew)
jobA.save();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment