Giter Club home page Giter Club logo

openstack-gitlab-executor's Introduction

GitLab CI Openstack executor

GitLab CI doesn't support Openstack as an executor but provides the ability to implement your own executor by using scripts to provision, run, and clean up CI environment. This repository contains such scripts as well as a Containerfile to build and configure a container image with Gitlab Runner that uses custom Openstack executor.

Building

git clone https://github.com/RedHatQE/openstack-gitlab-executor.git
cd openstack-gitlab-executor
podman build --build-arg GITLAB_RUNNER_VERSION=<version> -f Containerfile -t openstack-gitlab-runner

Configuration

The container expects the following environment variables:

Instance variables

FLAVOR - Default instance flavor reference

BUILDER_IMAGE - Default image to use for instance provisioning

NETWORK - Default network name

KEY_PAIR_NAME - Default SSH key pair name

SECURITY_GROUP - Default security group

USERNAME - Default username for SSH connection to instances

PRIVATE_KEY - Private key content

SSH_TIMEOUT - Timeout for establishing SSH connection

GitLab Runner variables

RUNNER_TAG_LIST - Tag list

REGISTRATION_TOKEN - Runner's registration token

RUNNER_NAME - Runner name

CI_SERVER_URL - Runner URL

RUNNER_BUILDS_DIR - Path to builds directory on the Openstack instance

RUNNER_CACHE_DIR - Path to cache directory on the Openstack instance

CONCURRENT - Limits how many jobs can run concurrently (default 1)

OS_AUTH_URL - Openstack authentication URL

OS_PROJECT_NAME - Project-level authentication scope (name or ID)

OS_USERNAME - Authentication username

OS_PASSWORD - Authentication password

OS_PROJECT_DOMAIN_NAME - Domain name or ID containing project

OS_USER_DOMAIN_NAME - Domain name or ID containing user

OS_REGION_NAME - Authentication region name

OS_IDENTITY_API_VERSION - Identity API version

OS_INTERFACE - Interface type

Usage

Create an env file with all variables:

cat env.txt

RUNNER_TAG_LIST=<your value>
REGISTRATION_TOKEN=<your value>
RUNNER_NAME=<your value>
CI_SERVER_URL=<your value>
RUNNER_BUILDS_DIR=<your value>
RUNNER_CACHE_DIR=<your value>
CONCURRENT=<your value>

FLAVOR=<your value>
BUILDER_IMAGE=<your value>
NETWORK=<your value>
KEY_PAIR_NAME=<your value>
SECURITY_GROUP=<your value>
USERNAME=<your value>

OS_AUTH_URL=<your value>
OS_PROJECT_NAME=<your value>
OS_USERNAME=<your value>
OS_PASSWORD=<your value>
OS_PROJECT_DOMAIN_NAME=<your value>
OS_USER_DOMAIN_NAME=<your value>
OS_REGION_NAME=<your value>
OS_IDENTITY_API_VERSION=<your value>
OS_INTERFACE=<your value>

Run a container:

podman run -it \
           -e PRIVATE_KEY="$(cat <private key filename>)"
           --env-file=env.txt \
           quay.io/redhatqe/openstack-gitlab-runner:latest

You can override instance configuration defaults by providing environment variables in a GitLab CI job config. For example, if you want to use another Openstack image to provision builder instance you should provide the following:

stages:
  - build

build:
  stage: build
  variables:
    BUILDER_IMAGE: my-custom-image
  tags:
    - some-tag
  script:
    - some command

openstack-gitlab-executor's People

Contributors

devil0000 avatar mshriver avatar victoremepunto avatar

Stargazers

 avatar  avatar  avatar  avatar  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

openstack-gitlab-executor's Issues

download gitlab-runner instead of building it

It may be way faster to download gitlab-runner instead of building it. This however is mostly style and build time optimisation.
Have a look at my ubuntu based variation of Dockerfile.
Not sure if you want to do this similar or if there is a prebuild version for redhat.

edit:
Also you may consider a ubuntu or alpine based dockerfile as well ;)
And many thanks for your version - i would have built the exactly same thing again

TagList not separating by comma

I tried to specify multiple tags like:

RUNNER_TAG_LIST="vm,openstack"

but it looks like the runner does not honor the "," but reads the whole string as tag. So there is just one tag registered with that runner "vm,openstack" and not two like "vm" and "openstack".

Is this a known limitation?

Add some resilience for duplicated image IDs

As of today, if you ask for an image name for your Openstack executor and that image exists more than once, the Openstack Python SDK fails on:

openstack.exceptions.DuplicateResource: More than one Image exists with the name 'my-duplicated-image-name'.

Perhaps it could be handed differently, taking the newest image ID for the provided name?

How to upload artifacts

When using the artifacts clause in gitlab-ci.yml, the job gives the following message:

Missing gitlab-runner. Uploading artifacts is disabled.

Is there any method to preserve artifacts created on the remote VM before it is terminated?

There's no tests

While working on #11 I created some tests , that I could not add to the PR itself, because there's no test infrastructure at all in this project.

I think one first step would be to refactor it, to add the source files into a directory, so that they can be imported from a test class to run them.

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.