Code Monkey home page Code Monkey logo

jenkins-helper's Introduction

jenkins-helper

Files

API Functions (NodeHelper.groovy)

The NodeHelper API contains helper functions to query basic machine stats in real time, add new machines, update/overwrite labels.

  • Get CPU count String getCpuCount(String computerName)
  • Get Installed memory Tuple getMemory(String computerName)
  • Get OS information Tuple getOsInfo(String computerName)
  • Get Kernel information Tuple getOsKernelInfo(String computerName)
  • Get Endian String getEndian(String computerName)
  • Get Location String getLocation(String computerName)
  • Get Description String getDescription(String computerName)
  • Get Home directory String getHomeDirectoryPath(String computerName)
  • Get free space in the home directory String getSpaceLeftInGb(String computerName)
  • Get Total installed disk space String getTotalSpace(String computerName)
  • Get Labels String getLabels(String computerName)
  • Add new Node String addNewNode(String newNodeName,String newNodeDescription,String newNodeRemoteFS,int newNodeNumExecutors,Mode newNodeMode,String newNodeLabelString,def launcher)
  • Add Label String addLabel(String computerName, String label)
  • Append Label String appendlabel(String computerName, String label)
  • Node Exists static boolean nodeIsOnline(String nodeLabel)

Space Monitoring (WorkspaceInfo.groovy)

Iterates over online nodes on Jenkins and prints the contents of the workspace directory along with the space they occupy

  • The computers it iterates over can be limited by input parameter, projectLabel
  • As of now, it only works for linux, aix, and mac

Create New Node (CreateNewNode.groovy)

Used to create new nodes with any basic labels

  • This job expects 3 parameters
    • String machineNames
      • Comma seperated host names of the machine(s)
    • String machineIPs
      • Comma seperated IP address of the machine(s)
    • String labelStrings
      • Labels you would like to be added to the machine.
      • Each label must be separated by spaces and labels for different machines must be separated by ,
      • If identical labels need to be applied to all the machines, only one set of labels need to be supplied

Update Machine Identifiers (UpdateMachineIdentifiers.groovy)

Used to update machine labels and description

  • The computers it iterates over can be limited by input parameter, projectLabel
  • The job expects 5 input parameters
    • boolean overWriteLabels
      • Does excatly as the name suggests, completely wipes previous labels
      • If set true, you do not need to pass a projectLabel
    • String labels
      • Labels you would like to be added to the machine.
      • Each label must be separated by spaces and labels for different machines must be separated by ,
      • If identical labels need to be applied to all the machines, only one set of labels need to be supplied
      • Use Cases:
        • Multiple machines, unique labels: machine1Label1 machine1Label2, machine2Label1 machine2Label2
        • Single or multiple machines, identical labels: Label1 Label2
    • String machineNames
      • Can either enter a list of names or a single name. For list seperate them with ","
    • boolean updateDescription
      • If this is set true, the job will update description
      • This has higher precedence than overWriteLabels
    • String projectlabel
      • This limits which machines will be touched
  • Use Cases:
    • Update labels:
      • Objective: add default labels(os, arch, and kernel)
      • Procedure: overWriteLabels is not set and only the machine name(s) is supplied
    • Overwrite Labels:
      • Objective: overwrite previous labels with new ones
      • Procedure: overWriteLabels is set and machine name(s) + labels are supplied
    • Append labels:
      • Objective: want to add a custom label.
      • Procedure: supply labels and machine names
    • Update description:
      • It adds CPU count, Disk space and installed RAM to the description
      • Procedure: have updateDescription parameter checked

How-to

Setup

Here are the instructions on how to add the library to Jenkins

Usuage

To use the API in a Jenkins job you'll need to add @Library('NodeHelper') _ to import the API.

TODOs

  • A job that pulls machine list from a inventory file and validates the names with those already on Jenkins. It also adds any labels mentioned in the inventory file to the machine on Jenkins, issue
  • CPU Information for a ZOS, issue
  • Logic to get Hypervisor information, issue
  • Move strings out to a config file, issue

jenkins-helper's People

Contributors

adambrousseau avatar andrew-m-leonard avatar bblondin avatar gdams avatar jdekonin avatar johnoliver avatar karianna avatar lasombra avatar m-davies avatar samuel-rubin avatar sophia-guo avatar steelhead31 avatar vermash avatar zdtsw avatar

Stargazers

 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  avatar

jenkins-helper's Issues

Validation for node names

Once we have figured out a naming convention for nodes we should implement a validation function in the API. As of right now it only checks for length greater than 2, it didn't make sense to check for just 0 or 1.

Jenkins job to do daily node maintenance

We'll need a job that runs periodically and validates the machines on Jenkins with those in the inventory file. Along with adding machines the job will also any labels mentioned in the inventory file.

Bug with cpu count on windows machine

For windows systems there is a bug with the script that updates the CPU count system variable. Even though the machine has 8 cores the system variable reports only 2.

z/OS version

Need to figure out the command(s) to get os version for zos machines

Move strings out to a config file

It would be nice to have all the hard coded strings, such as the ones one for labels sw.os., hw., slave jar location for command launcher, in a constants/config file. This would make the api easier to maintain.

Storage Monitoring Jenkins job

It would be nice to have a job that runs periodically and prints out folders along with the space they occupy. The output from this job can be used to decided which machines need cleanup.

[AIX, jdk11u] Build fails with: Attempting to resolve null as a branch

I noticed the build of jdk11u-dev failing with the following message:

Loading library openjdk-jenkins-helper@null
Examining [adoptium/jenkins-helper](https://github.com/adoptium/jenkins-helper)
Attempting to resolve null as a branch
Attempting to resolve null as a tag
ERROR: Could not resolve null

The first build in this failure was 219. The build immediately before give the following expected output:

Loading library openjdk-jenkins-helper@master
Examining [adoptium/jenkins-helper](https://github.com/adoptium/jenkins-helper)
Attempting to resolve master as a branch
Resolved master as branch master at revision 9fd063790c64a7cf2f9ee38c4bf4655f430d8be6

I am posting this here because it's the repo mentioned by the failing text, but I haven't had much time to spend on diagnosing the root cause. Please let me know if there is a different repo which is better and I can open an issue there instead.

Create helper methods for Jenkins computer api interactions

Part 1 of https://github.com/AdoptOpenJDK/openjdk-build/issues/2093

Introduce:

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.