Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing groovy configuration script for latest DockerTemplateBase #799

Merged
merged 3 commits into from
Dec 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions docs/attachments/docker-plugin-configuration-script.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ import jenkins.model.Jenkins

// parameters
def dockerTemplateBaseParameters = [
bindAllPorts: false,
bindPorts: '',
cpuShares: null,
image: 'jenkinsci/slave:latest',
pullCredentialsId: '',
dnsString: '',
network: '',
dockerCommand: '',
volumesString: '',
volumesFromString: '',
environmentsString: '',
extraHostsString: '',
hostname: '',
image: 'jenkinsci/slave:latest',
macAddress: '',
user: '',
extraGroupsString: '',
memoryLimit: null,
memorySwap: null,
network: '',
cpuShares: null,
shmSize: null,
bindPorts: '',
bindAllPorts: false,
privileged: false,
pullCredentialsId: '',
sharedMemorySize: null,
 tty: true,
volumesFromString: '',
volumesString: ''
tty: true,
macAddress: '',
extraHostsString: ''
]

def DockerTemplateParameters = [
Expand Down Expand Up @@ -56,11 +58,13 @@ DockerTemplateBase dockerTemplateBase = new DockerTemplateBase(
dockerTemplateBaseParameters.volumesFromString,
dockerTemplateBaseParameters.environmentsString,
dockerTemplateBaseParameters.hostname,
dockerTemplateBaseParameters.user,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor used here was deprecated in 2017; we need to stop using it.
Call new DockerTemplateBase(dockerTemplateBaseParameters.image) and then set all the remaining parameters.
...or try something like dockerTemplateBaseParameters as DockerTemplateBase or similar groovy "magic" to set everything.

...and either remove or update the // https://github.com/jenkinsci/docker-plugin/blob/docker-plugin-1.1.2/src/main/java/com/nirima/jenkins/plugins/docker/DockerTemplateBase.java comment that's pointing to an ancient version of the plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree if the DockerTemplateBase constructor is deprecated it makes sense to update the script properly. My groovy skills do not go far enough for that.
I hit upon the script from the official docs but it just errored out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @adamjwsuch, I have created a PR in your fork which addresses deprecation stuff.

Would you be able to review and merge it, please?

dockerTemplateBaseParameters.extraGroupsString,
dockerTemplateBaseParameters.memoryLimit,
dockerTemplateBaseParameters.memorySwap,
dockerTemplateBaseParameters.cpuShares,
dockerTemplateBaseParameters.sharedMemorySize,
 dockerTemplateBaseParameters.bindPorts,
dockerTemplateBaseParameters.shmSize,
dockerTemplateBaseParameters.bindPorts,
dockerTemplateBaseParameters.bindAllPorts,
dockerTemplateBaseParameters.privileged,
dockerTemplateBaseParameters.tty,
Expand Down