Skip to content

Instantly share code, notes, and snippets.

View mllrjb's full-sized avatar

Jason Miller mllrjb

View GitHub Profile
@mllrjb
mllrjb / ngName
Last active December 23, 2015 11:19
Angular directive to support expressions in `input.name`, pending merge of https://github.com/angular/angular.js/pull/3135.
.directive('ngName', function() {
return {
restrict: 'A',
require: ['^form', 'ngModel'],
link: function($scope, ele, attr, ctrl) {
var formCtrl = ctrl[0];
var ngModel = ctrl[1];
var name = $scope.$eval(attr.mppName);
if (ngModel.$name != name) {
formCtrl.$removeControl(ngModel);
function htmlEncode(value){
//create a in-memory div, set it's inner text(which jQuery automatically encodes)
//then grab the encoded contents back out. The div never exists on the page.
return $('<div/>').text(value).html();
}
function htmlDecode(value){
return $('<div/>').html(value).text();
}
angular.injector(['ng', 'ngSanitize']).get('$sanitize')('asdf<script>FooBar</script>')
@mllrjb
mllrjb / ant-installers.groovy
Created October 12, 2016 21:12
Jenkins init.groovy.d Ant Installer
import jenkins.model.*
import hudson.model.*
import hudson.tasks.*
import hudson.tools.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("hudson.tasks.Ant")
def versions = [
@mllrjb
mllrjb / jdk-installers.groovy
Last active July 4, 2020 10:42
Jenkins init.groovy.d JDK Installer
import jenkins.model.*
import hudson.model.*
import hudson.tools.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("hudson.model.JDK")
def versions = [
"jdk8": "jdk-8u102-oth-JPR"
@mllrjb
mllrjb / README.md
Last active February 14, 2019 14:15
Jenkins init.groovy.d LDAP Authentication

Usage

Set LDAP_BIND_USER and LDAP_BIND_PASSWORD environment variables in the system (e.g. when creating your Docker container, etc).

@mllrjb
mllrjb / README.md
Last active April 10, 2024 17:30
Jenkins init.groovy.d role-based authorization strategy

Usage

Set a system environment variable AUTHZ_JSON_URL that points to a JSON file with the following structure:

{
  "admins": [
    "groupA", 
    "userA"
 ],
@mllrjb
mllrjb / nodejs-installers.groovy
Last active November 29, 2017 08:51
Jenkins init.groovy.d Nodejs installer script
import jenkins.model.*
import hudson.model.*
import jenkins.plugins.nodejs.tools.*
import hudson.tools.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("jenkins.plugins.nodejs.tools.NodeJSInstallation")
def versions = [
@mllrjb
mllrjb / Jenkinsfile-GitHubCommitStatusSetter
Created October 13, 2016 18:42
Jenkinsfile Github Commit Status Example
#!groovy
step([$class: 'GitHubCommitStatusSetter',
contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: 'preflight-build'],
statusResultSource: [$class: 'ConditionalStatusResultSource',
results: [[$class: 'AnyBuildResult', message: 'Preflight build successful', state: 'SUCCESS']]]])
@mllrjb
mllrjb / Jenkinsfile
Created October 20, 2016 20:46
Jenkinsfile-gitUrl
#!groovy
node() {
// checkout clean code
stage("checkout") {
checkout scm
sh "git clean -fdx"
}
stage("gitUrl" ) {