1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| import com.nirima.jenkins.plugins.docker.DockerCloud import com.nirima.jenkins.plugins.docker.DockerTemplate import com.nirima.jenkins.plugins.docker.DockerTemplateBase import com.nirima.jenkins.plugins.docker.launcher.AttachedDockerComputerLauncher import io.jenkins.docker.connector.DockerComputerAttachConnector import jenkins.model.Jenkins
def dockerTemplateBaseParameters = [ bindAllPorts: false, bindPorts: '', cpuShares: null, dnsString: '', dockerCommand: '', environmentsString: '', extraHostsString: '', hostname: '', image: 'jenkinsci/slave:latest', macAddress: '', memoryLimit: null, memorySwap: null, network: '', privileged: false, pullCredentialsId: '', sharedMemorySize: null, tty: true, volumesFromString: '', volumesString: '' ]
def DockerTemplateParameters = [ instanceCapStr: '4', labelString: 'docker.local.jenkins.slave', remoteFs: '' ]
def dockerCloudParameters = [ connectTimeout: 3, containerCapStr: '4', credentialsId: '', dockerHostname: '', name: 'docker.local', readTimeout: 60, serverUrl: 'unix:///var/run/docker.sock', version: '' ]
DockerTemplateBase dockerTemplateBase = new DockerTemplateBase( dockerTemplateBaseParameters.image, dockerTemplateBaseParameters.pullCredentialsId, dockerTemplateBaseParameters.dnsString, dockerTemplateBaseParameters.network, dockerTemplateBaseParameters.dockerCommand, dockerTemplateBaseParameters.volumesString, dockerTemplateBaseParameters.volumesFromString, dockerTemplateBaseParameters.environmentsString, dockerTemplateBaseParameters.hostname, dockerTemplateBaseParameters.memoryLimit, dockerTemplateBaseParameters.memorySwap, dockerTemplateBaseParameters.cpuShares, dockerTemplateBaseParameters.sharedMemorySize, dockerTemplateBaseParameters.bindPorts, dockerTemplateBaseParameters.bindAllPorts, dockerTemplateBaseParameters.privileged, dockerTemplateBaseParameters.tty, dockerTemplateBaseParameters.macAddress, dockerTemplateBaseParameters.extraHostsString )
DockerTemplate dockerTemplate = new DockerTemplate( dockerTemplateBase, new DockerComputerAttachConnector(), DockerTemplateParameters.labelString, DockerTemplateParameters.remoteFs, DockerTemplateParameters.instanceCapStr )
DockerCloud dockerCloud = new DockerCloud( dockerCloudParameters.name, [dockerTemplate], dockerCloudParameters.serverUrl, dockerCloudParameters.containerCapStr, dockerCloudParameters.connectTimeout, dockerCloudParameters.readTimeout, dockerCloudParameters.credentialsId, dockerCloudParameters.version, dockerCloudParameters.dockerHostname )
Jenkins jenkins = Jenkins.getInstance()
jenkins.clouds.add(dockerCloud)
jenkins.save()
|