Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

DEPRECATED - A library of groovy scripts to be used in jenkins build pipelines

Notifications You must be signed in to change notification settings

coltenkrauter/jenkins-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

This repo is no longer maintained. I am keeping it around for reference for devs that want to write some groovy.

Jenkins Library

Instructions for setting up this Jenkins pipeline library which will query GitHub for the corresponding commit payload, save the commit author as an environment variable which is then used in the Slack notifier which posts messages as a bot user to your build-log slack channel.

Table of contents

Demo

Required Jenkins plugins

  • Pipeline: GitHub Groovy Libraries 1.0
  • HTTP Request Plugin 1.8.22

Quick start

These instructions are intended to assist in setting up this Jenkins pipeline library.

  1. Create a Jenkins credential (type: secret text) which contains a GitHub PAT

  2. Create a Slack app

    • Create a bot user
    • Create a Jenkins credential (type: secret text)
      • ID: slack-token
      • Secret: Bot User OAuth Access Token from the Slack app you created
  3. Fork this repo to your own GitHub account or GitHub organization

    • Update all of the configuration properties in Config.groovy
      • For GITHUB_TOKEN_CRED_ID you will need to use the credential id you made in step 1
  4. Configure Jenkins

    • In Jenkins instance, navigate to Manage Jenkins > Configure System and scroll down to the Global Pipeline Libraries section
    • Key Configuration settings
      • Default version: master
      • Load implicitly: False
      • Allow default version to be overridden: True
      • Include @Library changes in job recent changes: True
      • Retrieval method: Modern SCM
      • Source Code Management: GitHub
      • Credentials: Use the credential id you made in step 1
      • Owner: coltenkrauter (typically this is your orginazation or username)
      • Repository: jenkins-library
      • Behaviors: Discover branches, all branches
    • Of course, save the changes
  5. Import the library into groovy files

    • Add this to the top of files your Jenkinsfile
      #!/usr/bin/env groovy
      @Library("jenkins-library@master")
      
      import hudson.model.*;
      
      env.BUILD_START = new Date();
      env.SUCCESS = "true";
      

Checkout Jenkinsfile for a usage example.