Last active
July 28, 2020 08:22
-
-
Save jeykey/e6eec8974c111b43bd39d79b31074db1 to your computer and use it in GitHub Desktop.
Setup publish over ftp plugin configuration with groovy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hudson.util.Secret; | |
import jenkins.plugins.publish_over_ftp.BapFtpHostConfiguration; | |
import jenkins.plugins.publish_over_ftp.options.FtpPluginDefaults; | |
import net.sf.json.JSONObject; | |
import org.kohsuke.stapler.StaplerRequest; | |
import jenkins.model.*; | |
// Plugin configuration | |
def connectionName = "ftp"; | |
def hostname = "mydomain.com"; | |
def username = "user"; | |
def encryptedPassword = new Secret("password").getEncryptedValue(); | |
def remoteRootDir = "/"; | |
def port = 21; | |
def timeout = 300000; | |
def useActiveData = false; | |
def encoding = "UTF-8"; | |
def disableMakeNestedDirs = false; | |
def disableRemoteVerification = false; | |
def plugin = Jenkins.getInstance().getDescriptor("jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin"); | |
StaplerRequest req = [ | |
bindJSONToList: { a, b -> | |
return new Collections.SingletonList(new BapFtpHostConfiguration(connectionName, hostname, username, encryptedPassword, | |
remoteRootDir, port, timeout, useActiveData, encoding, disableMakeNestedDirs, disableRemoteVerification)); | |
}, | |
bindJSON : { a, b -> | |
return new FtpPluginDefaults(); | |
} | |
] as StaplerRequest; | |
plugin.configure(req, new JSONObject()); | |
plugin.save(); | |
println "FTP Publisher successfully configured."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment