Giter Club home page Giter Club logo

jenkins-automation's Introduction

Welcome to jenkins-automation

Build Status

Repos automated by Jenkins DSL

Jenkins automation is a library of helper functions to make continuous integration and deployment fast, easy and fun.

We use Job DSL to automate. We have further enhanced the functionality with a set of builders. You can see what they can do and how to use them in our API documentation.

Our collection of builders is still growing and we would love your contributions. Please see How to contribute.

Good place to start learning about job-dsl API:

http://jenkinsci.github.io/job-dsl-plugin/

Once you are little more comfortable, try the sandbox:

http://job-dsl.herokuapp.com/

If you would like to get started on it for your project a good place to start is our starter repo.

Guiding principles

  1. Make valuable
  2. Make it easy
  3. Make it fast
  4. Make it pretty

and always YAGNI, DRY and KISS

Configuration added to all jobs

Any jobs created by using these Builders get the following configuration added automatically:

  • Colorized Output (requires AnsiColor plugin)
  • Timestamps in the build log (requires Timestamper plugin)
  • Broken build claiming (requires Claim plugin)
  • Build Failure Analyzer (requires Build Failure Analyzer plugin)
  • Max 30 builds retained

If the emails property is set on a job, the job automatically gets configured with an Extended Email block, as well (requires Email Extension plugin)

Commonly used Jenkins Plugins that we support

Gradle init scripts

Within the path

gradle/init.d/init.gradle

There is a file that contains tasks that may be imported into other gradle builds by using the additional flag -I during normal gradle execution. Currently this file contains a task designed to copy the jar files of all dependencies of a project into a directory jac_dependencies. This tool may be useful when integrating with tools like OWASP

Common execution might be

./gradlew -I gradle/init.d/init.gradle copyDeps

jenkins-automation's People

Contributors

acrewdson avatar amymok avatar anselmbradford avatar chosak avatar contolini avatar dgreisen-cfpb avatar imuchnik avatar jls5177 avatar keitap avatar laminfaty avatar lfatty avatar m3brown avatar marcesher avatar ooblioob avatar orlandosoto avatar scotchester avatar sleitner avatar vickumar1981 avatar virtix avatar willbarton avatar yunghuffy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jenkins-automation's Issues

Consistently name example jobs

Right now, the example jobs in example-jobs are a mix of cases, hyphens, and so forth. Let's pick a consistent scheme and apply it to all example jobs

Proposal: all flow jobs get buildFlowTestAggregator

I propose that the FlowJob automatically add a buildFlowTestAggregator block:

configure { 
it / publishers << 'org.zeroturnaround.jenkins.flowbuildtestaggregator.FlowTestAggregator' {
      showTestResultTrend true
 }
}

Build flow jobs: options for simple jobs array, or a full buildflow config

@imuchnik
This stems from a conversation I had with Vic this morning about OaH's build flow and how it's not a straightforward list of jobs but instead has a parallel block.

My comment to Vic was to keep this as simple as possible, not get clever or fancy, not reinvent any wheels, and not fall into the trap of the "wrapper" being more complicated than the thing it's wrapping.

I recommended having our build flow builder offer 2 possibilities for creating a flow job: 1) an array of job names; 2) a closure that contains the entire build flow

For #2, I should've said string, based on my now-corrected understanding of buildflow job-dsl (https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.DslFactory.buildFlowJob)

Basically, I should be able to do something like:

new BuildFlowBuilder(blahblah, jobs: ["job1","job2"])

Or

new BuildFlowBuilder(blahblah, jobConfig: '''
build("job1")
parallel {
  build("job2")
  build("job3")
}
build("job4")
'''

Or some such thing. But nothing more complicated than that. Basically, make easy things easy (option #1), and hard things possible (option #2), but without making option #2 so onerous (by being clever or fancy) that people rip out their hair.

Thoughts?

jenkins-automation & jenkins-as-code-starter-project seed job

Appreciate this maybe more an issue with the https://github.com/cfpb/jenkins-as-code-starter-project repo

I'd like to check out this project but am having issues with the seed job. https://github.com/cfpb/jenkins-as-code-starter-project/blob/master/README.md#creating-the-seed-job states that you will need a multiscm for both the automation and jenkins as code repo. Assuming this is not directing me to checkout both repos to the same top level directory, I have:

ls -ll /var/jenkins_home/jobs/jenkins-dsl-seed/workspace/
total 8
drwxr-xr-x 8 jenkins jenkins 4096 Jan 30 14:52 jenkins-automation
drwxr-xr-x 7 jenkins jenkins 4096 Jan 30 14:52 jenkins-jobs

but when I run this job, looking for jenkins-jobs/jobs/*.groovy I'm getting unable to resolve class BaseJobBuilder errors, which is to be expected. I have tried setting the additionalClasspath: jenkins-automation/src/main/groovy to no avail. My seed jobs is:

job('seed') {
    multiscm {
        git {
            remote {
                name('origin')
                github('cfpb/jenkins-automation', 'https')
            }
            branch('*/master')
                configure { node ->
                    node / 'extensions' << 'hudson.plugins.git.extensions.impl.RelativeTargetDirectory' {
                        relativeTargetDir('jenkins-automation')
                    }
                }
        }
        git {
            remote {
                name('origin')
                github('joshmyers/jenkins-jobs', 'https')
            }
            branch('*/master')
                configure { node ->
                    node / 'extensions' << 'hudson.plugins.git.extensions.impl.RelativeTargetDirectory' {
                        relativeTargetDir('jenkins-jobs')
                    }
                }
        }
    }
    steps {
        gradle 'clean test'
        dsl {
            external 'jobs/**/*Jobs.groovy'
            additionalClasspath 'jenkins-automation/src/main/groovy'
        }
    }
}

It works if I just clone jenkins-automate and run the example jobs from the seed, but I'd rather not fork and hack on this repo and use the jenkins-as-code-starter-project.

Any ideas?

Checkmarx example job failing

When I set up a job to run the example jobs, the checkmarx job fails with:

ERROR: (ScmUtils.groovy, line 15) No such property: url for class: java.lang.String

How do you use BaseJob directly in a script?

The examples.md show usage of BaseJob, but the example has this:

build(factory)

However, factory does not exist in a script.

All other examples of BaseBuilder are inside of other builders, where factory does exist

Please correct this example

Convert email into a reusable, parameterized configure block

We can make the editable email config more useful by turning it into a reusable, parameterized configure block.

The BaseJobBuilder and friends can then use it, as can any other jobs that don't use the builders.

suggested signature something like:

    static Closure editableEmail(List<String> triggers = ["Failure", "Fixed"], List<String> emails=[], sendToDevelopers=false, includeCulprits=false, sendToRecipientList=true) {

    }

The purpose here is to make it really easy to do the thing that we need to do most often with email, which is send an email with default subject, default body, a configurable recipient list, and only to recipients (sending to developers and culprits is often a bad idea because we don't want internal jenkins emails going to external contributors, who might show up in the developers or culprits list)

Jobs that need more configuration can still easily use editable email directly without this helper, which is why it's important we keep this block simple and not load it up with all manner of configurability

Error using CommonUtils.addExtendedEmail() in my own job

I'm trying to use CommonUtils.addExtendedEmail() in a builder of my own. Here's the code:

class QuMatrixJobBuilder {
...
    Job build(DslFactory factory) {
        factory.matrixJob(name) {
            it.description this.description
            CommonUtils.addDefaults(delegate)
            CommonUtils.addExtendedEmail(delegate, emails)
        }
    }
}

And here's the error when I run the seed job:

ERROR: (CommonUtils.groovy, line 41) No signature of method: javaposse.jobdsl.dsl.jobs.MatrixJob.extendedEmail() is applicable for argument types: (java.lang.String, jenkins.automation.utils.CommonUtils$_addExtendedEmail_closure2_closure7) values: [[email protected], [email protected], ...]

Note that CommonUtils.addDefaults() works just fine

Now, if I try it outside the context of a custom builder, and just adding it to an existing job created with one of the JAC builders, I get the same error:

new QuTaskBuilder(
        name: "qu-virtualenv-tester",
).build(this).with {
    CommonUtils.addExtendedEmail(delegate, Config.emails)
}

Same error as above:

ERROR: (CommonUtils.groovy, line 41) No signature of method: javaposse.jobdsl.dsl.jobs.FreeStyleJob.extendedEmail() is applicable for argument types: (java.lang.String, jenkins.automation.utils.CommonUtils$_addExtendedEmail_closure2_closure7) values: [emails redacted, ...]

what is the status?

Hey @imuchnik @Ooblioob. Glad to see continued development! I'm getting ready to set up a CI pipeline and was wondering whether the project is in a state that I can use it? Should I work off the ooblioob fork, or should I stick with the master? Has config changed? Have things settled down with development, or are you finding lots of things you still need to break?

I also saw that you started building some wrappers. Are those jobdsl extensions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.