Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raphaelcastaneda/3aca35f15572137fa2b5f67d4ed59cb9 to your computer and use it in GitHub Desktop.
Save raphaelcastaneda/3aca35f15572137fa2b5f67d4ed59cb9 to your computer and use it in GitHub Desktop.
Configuring jenkins artifactory plugin from a groovy script
import jenkins.model.*
import org.jfrog.hudson.ArtifactoryBuilder
import org.kohsuke.stapler.Stapler
import net.sf.json.JSONObject
def instance = Jenkins.getInstance()
def descriptor = instance.getDescriptor(ArtifactoryBuilder.class);
def artifactoryCreds = [
username: "admin",
password: "thisistotallynotmypassword"
]
def params = [
useCredentialsPlugin: false,
artifactoryServer: [
[
serverId: "a-test-server",
artifactoryUrl: "http://artifactory-artifactory-nginx/artifactory",
timeout: 300,
bypassProxy: false,
deployerCredentialsConfig: artifactoryCreds,
resolverCredentialsConfig: artifactoryCreds
]
]
]
stapler = Stapler.getCurrentRequest()
JSONObject json = new JSONObject(params)
descriptor.configure(stapler, json)
println descriptor.getArtifactoryServers()[0].getProperties().toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment