Groovy web console

subscribe to the feed Subscribe
to this
site

ignore jenkins commits

Published 2 months ago by jaxzin
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class Build {Collection<ChangeSet> changeSets}
class ChangeSet {Object[] items}
class ChangeSetEntry {User author; Collection<AffectedFile> affectedFiles}
class AffectedFile {String path}
class User{String id}

def currentBuild = 
    new Build(
        changeSets: [
            new ChangeSet(
                items: [
                    new ChangeSetEntry(
                        author: new User(id: 'real_user'),
                        affectedFiles: [
                            new AffectedFile(path: "runtime/test.txt")
                        ]
                    ),
                    new ChangeSetEntry(
                        author: new User(id: 'jenkins'),
                        affectedFiles: [
                            new AffectedFile(path: "runtime/test.txt")
                        ]
                    )
                ]
            )
        ]
    )

println !currentBuild.changeSets*.items.flatten().every{it?.author?.id?.equalsIgnoreCase('jenkins')}