Giter VIP home page Giter VIP logo

jcs's Introduction

Jenkins Cloud Slave (jcs)

Jenkins Cloud Slave is a command line interface to create Jenkins slave servers. With that, new Jenkins slaves can be dynamically created eg. on public clouds (AWS) or private clouds (OpenStack).

Installation

You can install jcs inside of a virtualenv:

virtualenv venv
source venv/bin/activate
pip install git+git://github.com/toabctl/jcs.git#egg=jcs[aws,obs,jenkins]

Usage

Some examples how to use jcs. All the following calls to jcs expect that some environment variables are set (the parameters can also be given as CLI switches, eg. --jenkins-url but for shorter commands, we use the env vars here).

For Jenkins:

export JENKINS_URL=https://localhost
export JENKINS_USERNAME=user
export JENKINS_PASSWORD=superSecure!

When doing something with AWS, also these are needed:

export AWS_ACCESS_KEY_ID=my-access-key
export AWS_SECRET_ACCESS_KEY=my-secret-access-key

When doing something with OpenStack:

export OS_CLOUD=my-cloud

where my-cloud needs to be defined in the clouds.yaml file.

All-in-one - Create a Jenkins slave on AWS/EC2 from an OBS image

Assuming you have an EC2-ready image on the OpenBuildService (OBS) that you want to use as a jenkins slave, do:

jcs create --key-name my-keypair-name --jenkins-credential cred-description \
    http://download.suse.de/ibs/Devel:/Storage:/images/openSUSE_Leap_15.1/minimal-openSUSE-Leap-15.1.aarch64-ec2-hvm.raw.xz \
    jenkins-slave-name

Where --key-name is the key that must be available on the cloud to be able to login into the instance. --jenkins-credential is the credential that is registered inside the Jenkins master. Here, use the description of the credential (not the ID). The image from OBS is only downloaded once and cached in ~/.cache/jcs. The image will only downloaded again, if the sha256 changed.

To delete the whole stack (Jenkins node and EC2 instance), do:

jcs delete jenkins-slave-name

Note: This only works if the slave got created with jcs create because it uses EC2 tags to build the relation between the jenkins slave name and the EC2 instance.

Add node as Jenkins slave

If you already have a node that should be registered as a Jenkins slave, all you need are Jenkins credentials (for creating the node in Jenkins), some node information and a Jenkins credential (to log into the node):

export JENKINS_URL=https://localhost
export JENKINS_USERNAME=user
export JENKINS_PASSWORD=superSecure!

jcs jenkins-node-add my-slave-hostname-or-ip slave-name "slave description" \
  slave-credentials "label1 label2"
  • The slave_credentials needs to be the "credential description" (not the ID). This is a limitation of jenkinsapi which is used to talk to Jenkins.
  • Instead of using the JENKINS_* enviroment variables, command line switches (--jenkins-url, --jenkins-username and --jenkins-password) are also available. See jcs -h.

Remove node as Jenkins slave

Similar to jenkins-node-add, removing the node can be done with:

jcs jenkins-node-remove slave-name

The environment variables (JENKINS_*) or command line switches (--jenkins-*) must be set when executing this command.

Download an OBS image

Downloading an image from OBS:

jcs obs-image-download http://download.suse.de/ibs/Devel:/Storage:/images/openSUSE_Leap_15.1/minimal-openSUSE-Leap-15.1.x86_64-ec2-hvm.raw.xz

The downloaded images are cached under ~/.cache/jcs.

jcs's People

Contributors

kshtsk avatar toabctl avatar

Watchers

 avatar  avatar  avatar

Forkers

kshtsk

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.