Giter Club home page Giter Club logo

jenkins-configuration-as-code-sandbox's Introduction

Jenkins Configuration as Code Sandbox

This is an example of Jenkins Configuration as Code with GitLab.

This is a fully working CI/CD setup with Jenkins and GitLab where everything is put under version control:

This allows for you to:

  • Do local development of the CI/CD setup. Giving self confidence to do refactorings and keep all the scripts clean.
  • Allow code review of changes to the installation. Enable anyone to contribute to an innovative build CI/CD process.
  • Manage different installations in different branches. Push to the branch of installation X and X will automatically be re-configured.

It also demonstrates a pattern where a "contract" is established between application repositories and the infrastructure. A jenkins-settings.json-file is created in the application repositories to tweak the build process. This means:

  • The pipeline code can be developed generically. Pipelines are not created to take care of a specific repo. Generic features are created, and documented, and the application developers chooses what features that should apply to thir repo. By editing /jenkins-settings.json in their repo. A default set of settings are derived and applied if no properties found in the repo.
  • The solution becomes scalable and can handle a vast amount of application repositories. With low effort needed for support.

Usage

Start Environment

docker-compose up -d 

GitLab will be available in a few moments at http://localhost/ and you can login with credentials found here.

Jenkins now available on: http://localhost:8080/

JobDSL docs available at: http://localhost:8080/plugin/job-dsl/api-viewer/index.html

Destroy Environment

docker-compose down -v --rmi local

all services are down and data lost

Enjoy!

jenkins-configuration-as-code-sandbox's People

Contributors

agdula avatar chludwig-haufe avatar tomasbjerre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jenkins-configuration-as-code-sandbox's Issues

Unable to complete Docker Compose build

Hi , I'm unable to complete this build due to changes in Jenkins. One step is "CANCELED" and another has an "ERROR" . Please see the most recent output here:

=> CANCELED [jenkins-configuration-as-code-sandbox-gitlab-setup 2/5] RUN apt-get update &&  apt-get install -y software-properties-common &&  add-apt-repository -y ppa:deadsnakes/ppa &&  apt-mark hold python2 python2-minimal python2.7 python2.7-mi  52.7s
 => [jenkins-configuration-as-code-sandbox-jenkins-docker 2/6] RUN mkdir /var/jenkins_home/casc_configs                                                                                                                                                    1.4s
 => [jenkins-configuration-as-code-sandbox-jenkins-docker 3/6] COPY ./jenkins.yaml /var/jenkins_home/casc_configs/jenkins.yaml                                                                                                                             0.1s
 => [jenkins-configuration-as-code-sandbox-jenkins-docker 4/6] RUN apt-get update       && apt-get install -y iproute2       && rm -rf /var/lib/apt/lists/*                                                                                               22.0s
 => ERROR [jenkins-configuration-as-code-sandbox-jenkins-docker 5/6] RUN install-plugins.sh   configuration-as-code   blueocean   job-dsl   cloudbees-folder   workflow-aggregator   pipeline-utility-steps   generic-webhook-trigger   git-changelog   v  1.4s
------
 > [jenkins-configuration-as-code-sandbox-jenkins-docker 5/6] RUN install-plugins.sh   configuration-as-code   blueocean   job-dsl   cloudbees-folder   workflow-aggregator   pipeline-utility-steps   generic-webhook-trigger   git-changelog   violation-comments-to-gitlab:
#0 0.954 WARN: install-plugins.sh has been removed, please switch to jenkins-plugin-cli
------
failed to solve: process "/bin/sh -c install-plugins.sh   configuration-as-code   blueocean   job-dsl   cloudbees-folder   workflow-aggregator   pipeline-utility-steps   generic-webhook-trigger   git-changelog   violation-comments-to-gitlab" did not complete successfully: exit code: 1

Error OCI runtime failed jenkins-wrapper.sh cannot exectute

When I run the docker compose I am getting an error about being unable to execute jenkins-wrapper.sh. If I make this file executable I get other errors:
ERROR: for jenkins-configuration-as-code-sandbox_gitlab-setup_1 Cannot start service gitlab-setup: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: "/bootstrap/main.sh": permission denied": unknown

ERROR: for gitlab-setup Cannot start service gitlab-setup: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: "/bootstrap/main.sh": permission denied": unknown

setup-gitlab.sh fails

On running the setup-gitlab.sh the following error occurs, even after configuring git identity.

Jenkins-configuration-as-code-sandbox/gitlab-docker/setup/project1/git-repo/.git/

*** Please tell me who you are.

Run

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect e-mail address (got 'me@here.(none)')
error: src refspec master does not match any
error: failed to push some refs to 'http://root:thepassword@localhost/root/project20name.git'

fix for gitlab 13.9.4

Hi,

This is a great project. Thanks for sharing!

The most recent version of gitlab is not compatible with create-personal-access-token.sh.
I've made a PR for a python version of the script

vitalyisaev2/gitlab_token@f00ab87

You could apply the changes to the script yourself... or maybe consider using approach from this fork
agdula@f8051db

Token Credential Question

I have been successful at installing your plugin in Jenkins and configuring a freestyle job that uses the plugin so that I can reference variables and headers sent from the GitHub JSON based payload.

The Jenkins job that is working right now is configured with a regular hard-coded token, not the Jenkins credential based token option that you provide. I have been trying to migrate away from the hard-coded token to the credential based token without success. In Jenkins I successfully create a user/password based credential without problem but that new Jenkins credential does not display as an option in the “Token Credential” drop down.

Any advice on what I might be doing wrong?

Jenkins fails to start due to dropped Job DSL plugin method

Hi,

the Jenkins service failed to start for me with a complaint that there is no applicable method concurrentBuild() for an argument of boolean type. I finally found that this method was deprecated in version 1.76 of the Job DSL plugin and has apparently been removed since.

I could fix this with the following patch:

diff --git a/jenkins-docker/jenkins.yaml b/jenkins-docker/jenkins.yaml
index 55bb310..b1f6769 100644
--- a/jenkins-docker/jenkins.yaml
+++ b/jenkins-docker/jenkins.yaml
@@ -58,7 +58,9 @@ jobs:
   - script: >
       pipelineJob('Create Jobs Pipeline') {
         quietPeriod(0)
-        concurrentBuild(false)
+        properties {
+          disableConcurrentBuilds()
+        }
         logRotator {
           numToKeep(10)
         }

Cheers,
Christoph

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.