Created
April 15, 2020 18:58
-
-
Save raphaelcastaneda/3aca35f15572137fa2b5f67d4ed59cb9 to your computer and use it in GitHub Desktop.
Configuring jenkins artifactory plugin from a groovy script
This file contains hidden or 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 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