Giter Club home page Giter Club logo

jenkins-vagrant's Introduction

This is a Vagrant Environment for a Continuous Integration server using the Jenkins daemon.

This configures Jenkins through CLI/JNLP and Groovy scripts to:

  • Enable the simple Logged-in users can do anything Authorization security policy.
  • Add a SSH public key to vagrant user account and use it to access the CLI.
    • Except on Windows; there it uses JNLP4/HTTPS to connect to the Jenkins Master from a Windows Service. Only a Windows Service has the needed permissions to run integration tests that use the WCF net.pipe transport and to build unity projects.
  • Optionally use LDAP user authentication.
  • Add and list users.
  • Install and configure plugins.
  • Setup GitLab integration (assumes rgl/gitlab-vagrant is already deployed)
  • Setup nginx as a Jenkins HTTPS proxy and static file server.
  • Create Freestyle project job.
  • Create Pipeline job.
  • Create Multibranch Pipeline job.
  • Add a Ubuntu Linux slave node.
  • Add a Windows slave node.
    • With docker-ce (default) or docker-ee (you need to uncomment it from the Vagrantfile).
    • With enabled long path support on the OS and chocolatey.
    • With MSYS2 to be able to use the Execute shell build step.
    • With Unity Editor.
      • You still need to activate it by running Unity Hub.
  • Add a macOS slave node.

NB If you are new to Groovy, be sure to check the Groovy Learn X in Y minutes page.

These are the machines and how they are connected with each other:

Usage

Build and install the Ubuntu 20.04 Base Box.

Build and install the Windows 2022 Base Box.

Build and install the macOS Base Box.

Add the following entry to your /etc/hosts file:

10.10.10.100 jenkins.example.com
10.10.10.102 windows.jenkins.example.com

If you want to use LDAP for user authentication, you have to:

  1. have rgl/windows-domain-controller-vagrant up and running at ../windows-domain-controller-vagrant.
  2. uncomment the config_authentication='ldap' line inside provision.sh.

Run vagrant up --no-destroy-on-error jenkins to launch the master. See its output to known how to login at the local Jenkins home page as admin (you can also login with one of the example accounts, e.g. alice.doe and password password).

NB nginx is setup with a self-signed certificate that you have to trust before being able to access the local Jenkins home page.

Run vagrant up --no-destroy-on-error ubuntu to launch the Ubuntu slave.

Run vagrant up --no-destroy-on-error windows to launch the Windows slave. Portainer is available at http://windows.jenkins.example.com:9000/.

Run vagrant up --no-destroy-on-error macos to launch the macOS slave. NB you first need to download Xcode_8.1.xip. After provisioning you can delete it, as Xcode_8.1.cpio.xz will take its place as a more efficient way to install Xcode.

Email notifications are sent to a local MailHog SMTP server running at localhost:1025 and you can browse them at http://jenkins.example.com:8025.

Groovy Snippets

Show Object Properties

def getObjectProperties(obj) {
    def filtered = ['class', 'active']

    properties = obj.metaClass.properties
        .findAll {it.name != 'class' && it.name != 'metaClass'}
        .inject([:]) {acc, e -> acc[e.name] = e.getProperty(obj); acc}

    properties
        .sort {it.key}
        .collect {it}
        .findAll {!filtered.contains(it.key)}
        .join('\n')
}

project = Jenkins.instance.getItem('MailBounceDetector-multibranch-pipeline')
getObjectProperties(project)

Create Api Token

// create an user api token.
// see http://javadoc.jenkins-ci.org/hudson/model/User.html
// see http://javadoc.jenkins-ci.org/jenkins/security/ApiTokenProperty.html
// see https://jenkins.io/doc/book/managing/cli/
import hudson.model.User
import jenkins.security.ApiTokenProperty

u = User.getById('alice.doe', false)
p = u.getProperty(ApiTokenProperty)
t = p.tokenStore.generateNewToken('token-name')
u.save()
println t.plainValue

Reference

jenkins-vagrant's People

Contributors

rgl 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

Watchers

 avatar  avatar  avatar  avatar  avatar

jenkins-vagrant's Issues

Remove vagrant-triggers instructions

โžœ jenkins-vagrant git:(master) vagrant up jenkins

WARNING: Vagrant has detected the `vagrant-triggers` plugin. This plugin conflicts
with the internal triggers implementation. Please uninstall the `vagrant-triggers`
plugin and run the command again if you wish to use the core trigger feature. To
uninstall the plugin, run the command shown below:

  vagrant plugin uninstall vagrant-triggers

Note that the community plugin `vagrant-triggers` and the core trigger feature
in Vagrant do not have compatible syntax.

To disable this warning, set the environment variable `VAGRANT_USE_VAGRANT_TRIGGERS`.
Bringing machine 'jenkins' up with 'virtualbox' provider...
==> jenkins: Running triggers before up...
/Users/anshul.sharma/.vagrant.d/gems/2.4.4/gems/vagrant-triggers-0.5.3/lib/vagrant-triggers/dsl.rb:90:in `method_missing': undefined method `only_on=' for #<VagrantPlugins::Triggers::DSL:0x00000001012823f8> (NoMethodError)

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.