Skip to content

Instantly share code, notes, and snippets.

View smalltown's full-sized avatar

smalltown

View GitHub Profile
repos:
- id: /.*/
# apply_requirements sets the Apply Requirements for all repos that match.
apply_requirements: [mergeable]
# workflow sets the workflow for all repos that match.
# This workflow must be defined in the workflows section.
allowed_overrides: [workflow]
@smalltown
smalltown / Jenkins_Job_DSL_GitLab_Trigger
Created October 21, 2017 01:29
Jenkins job DSL for integrating GitLab
import jenkins.model.Jenkins
// define global variable
def job_folder = 'job_folder'
def job_name = 'job_name'
pipelineJob("${job_folder}/${job_name}") {
triggers {
gitlab {
import groovy.json.*
def deploy(phase, version, user, branch, status = 'Success', region = 'Oregon', channel = 'none', repoer = 'true', repo_host, repo_owner) {
def slack_info = slack_info.load()
def http_client = new com.droi.pipeline.jenkins.httpRequest(slack_info.hook_protocol, slack_info.hook_fqdn, slack_info.hook_port.toInteger())
def header = ["Content-Type": "application/json"]
def url = "${slack_info.hook_protocol}://${slack_info.hook_fqdn}/${slack_info.hook_uri}"
def response = [:]
# clean old properties and script file
rm -rf *
# copy the latest properties and script file
cp -rf /var/lib/jenkins/dsl-repo/config ./
cp -rf /var/lib/jenkins/dsl-repo/dsl ./
cp -rf /var/lib/jenkins/dsl-repo/pipeline ./
# reload pipeline global library
rm -rf /tmp/workflowLibs
//
// This Groovy snippet is used for Jenkins Job DSL groovy script,
// when ...
// 1. enable Jenkins Global Security
// 2. use pipelineJob
// 3. want to approve pipeline cps automatically
//
import jenkins.model.Jenkins
search("groups", "*:*").each do |group_data|
group group_data["id"] do
gid group_data["gid"]
members group_data["members"]
end
end
#
# Cookbook Name:: users
# Recipe:: default
#
# Copyright (c) 2016 The Authors, All Rights Reserved.
search("users", "*:*").each do |user_data|
user user_data["id"] do
comment user_data["comment"]
uid user_data["uid"]
{
"id": "clowns",
"gid": 3000,
"members": ["bobo", "frank"]
}
{
"id": "frank",
"comment": "Frank Belson",
"uid": 2001,
"gid": 0,
"home": "/home/frank",
"shell": "/bin/bash"
}
{
"id": "bobo",
"comment": "Bobo T. Clown",
"uid": 2000,
"gid": 0,
"home": "/home/bobo",
"shell": "/bin/bash"
}