Issue using standalone job dsl jar with authorizationMatrixProperty permission

129 views
Skip to first unread message

Lars Rønhøj

unread,
Mar 10, 2021, 4:38:36 AM3/10/21
to job-dsl-plugin
Hello,

I am trying to set up a gradle task to run the standalone jar job-dsl-core-1.77-standalone.jar and build config.xml files for my jobs.

I am loading the matrix-auth jenkins plugin onto the classpath but i still get this error suggesting jobdsl doesn't load it correctly:

Caused by: javaposse.jobdsl.dsl.DslScriptException: (Util.groovy, line 6) No signature of method: javaposse.jobdsl.dsl.helpers.properties.FolderPropertiesContext.authorizationMatrixProperty() is applicable for argument types: (dk.nsp.seed.Util$_createFolder_closure1$_closure8$_closure9) values: [dk.nsp.seed.Util$_createFolder_closure1$_closure8$_closure9]

The execption is thrown from this method.

static void createFolder(del, name, suppliers, inherit) {
    del.folder(name) {
        properties {
            authorizationMatrixProperty {
                suppliers.each{ supplier ->
                    permissions(["hudson.model.Item.Read:${supplier}",
                                "hudson.model.Item.Build:${supplier}",
                                "hudson.model.Item.Cancel:${supplier}",
                                "com.cloudbees.plugins.credentials.CredentialsProvider.View:${supplier}"])
                }
                if (inherit) {
                    inheritAuthMatrix(getDelegate())
                } else {
                    nonInheritAuthMatrix(getDelegate())
                }
            }
        }
    }
}


I would very much appreciate a hint sending me in the right direction to solve this issue, as i don't know how jobdsl injects this extension properly.

This my gradle file just in case. Its pretty basic it just populates deps and calls standalone jar main class.

apply plugin: 'java'

defaultTasks 'libs'

repositories {
    maven { url 'http://repo.jenkins-ci.org/releases/' }
    jcenter()
}

configurations {
    libs
    main
}

dependencies {
    libs group: 'org.yaml', name: 'snakeyaml', version: '1.17'
    main group: 'org.jenkins-ci.plugins', name: 'job-dsl-core', version: '1.77', classifier: 'standalone'
    main group: 'org.jenkins-ci.plugins', name: 'matrix-auth', version: '2.0', ext: 'jar'
}

task cleanLibs(type: Delete) {
    delete 'libs'
    delete 'mains'
}

task runMain (dependsOn: 'libs', type: JavaExec) {
    classpath = configurations.libs + configurations.main + files('jobs')
    // main = 'javaposse.jobdsl.Run'
    main = 'com.simontuffs.onejar.Boot'
    args 'jobs/main.groovy'
}

task libs(type: Copy) {
    into 'libs'
    from configurations.libs
}

task runTest (dependsOn: 'libs', type: JavaExec) {
    classpath = configurations.libs + configurations.main + files('jobs')
    // main = 'javaposse.jobdsl.Run'
    main = 'com.simontuffs.onejar.Boot'
    args 'jobs/test.groovy'
}

task mains(type: Copy) {
    into 'mains'
    from configurations.main
}


/Lars

Denis Mone

unread,
Mar 10, 2021, 6:04:47 AM3/10/21
to job-dsl...@googlegroups.com
Hi there.
From the error message it doesn't seem that the matrix-auth plugin isn't loaded, but that the method you are trying to use (in order to configure the authorization) does not exist.
Going through the jobdsl docs i found out this example which adds permissions, albeit to a job and not a folder. Still it may be useful to you so i will paste the link here:

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/555e2bda-82eb-44d0-a249-39b75e841ac8n%40googlegroups.com.

Lars Rønhøj

unread,
Mar 10, 2021, 6:09:51 AM3/10/21
to job-dsl...@googlegroups.com
I could agree with you except that it works when i run the jobdsl on a
backup of our jenkins. So i assume its me not loading the maxtrix auth
plugin properly.

De bedste hilsner / Best Regards

Lars Rønhøj
Software Developer

Arosii A/S
Åbogade 15 · DK-8200 Aarhus N

M. (+45) 2614 5515
T. (+45) 7027 3010
l...@arosii.com · www.arosii.com
> You received this message because you are subscribed to a topic in the Google Groups "job-dsl-plugin" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/job-dsl-plugin/9ZqHvUYQTtU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to job-dsl-plugi...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/CADCvpUfWNMw7V5ZFuNo8HUbFY45K8Yb4ARJmfJG9aZnX2_HJxg%40mail.gmail.com.

Lars Rønhøj

unread,
Mar 11, 2021, 6:28:31 AM3/11/21
to job-dsl...@googlegroups.com
The problem seemed to be the same for all custom properties. Thus i
took your advice and changed contents of all properties to configure
blocks. This fixed my issues.

De bedste hilsner / Best Regards

Lars Rønhøj
Software Developer

Arosii A/S
Åbogade 15 · DK-8200 Aarhus N

M. (+45) 2614 5515
T. (+45) 7027 3010
l...@arosii.com · www.arosii.com

Reply all
Reply to author
Forward
0 new messages