Child pages
  • Update maven jobs to use the post build task to deploy artifacts

Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

This script updates all maven jobs having a deploy goal by install and activate the post build step to deploy artifacts at the end of the build
The script also overrides the parameter of the job to ensure you are archiving the artifacts (this is mandatory by the post build task).

import java.util.*
import hudson.model.*
import hudson.maven.*
import hudson.maven.reporters.*
import hudson.matrix.*
import hudson.tasks.*

hudson.model.Hudson.instance.items.findAll{job -> job.isBuildable() && job instanceof MavenModuleSet}.each {
job -> 
  if (job.goals.indexOf("deploy")>0) {
    println("* Must update goals (deploy -> install) : " + job.goals)
    def newGoals = job.goals.replaceAll("deploy", "install");
    println("* New goals : " + newGoals)
    // Comment the 3 following lines for a first run to check goals modifications without modifying anything
    job.goals = newGoals
    job.archivingDisabled = false // It is necessary to archive artifacts to deploy them after the build
    job.publishers.replace(new hudson.maven.RedeployPublisher(null, null, true, false));
    println("* Redeploy publisher added");
  } else {
    println("* This maven job doesn't deploy its artifacts");
  • No labels

1 Comment

  1. Unknown User (aheritier)

    wrong comment