Giter Site home page Giter Site logo

praqma / jenkins4casc Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 14.0 51 KB

Dockerfile repository for a Jenkins preconfigured with Jenkins Configuration as Code plugin

Dockerfile 100.00%
jenkins jenkins-ci configuration-as-code docker-image infrastructure-as-code

jenkins4casc's Introduction

jenkins4casc

Repository for the Praqma custom Docker image using the new Configuration as Code plugin.

How to use the Docker image

Basically the same way as you would use the official Jenkins Docker image. With one difference. If you start a container using this image with an environment variable CASC_JENKINS_CONFIG you can configure Jenkins to be configured on startup. And if you point to a configuration file from an URL you can reconfigure without the need for a restart.

Example: Minimum Configuration

docker run -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home -e CASC_JENKINS_CONFIG=https://raw.githubusercontent.com/Praqma/jenkins4casc/master/jenkins-minimal-example.yaml praqma/jenkins4casc

We added the switch

-e CASC_JENKINS_CONFIG=https://raw.githubusercontent.com/Praqma/jenkins4casc/master/jenkins-minimal-example.yaml

To point to the smallest possible configuration of Jenkins with Jenkins configuration as code:

jenkins:
  systemMessage: "The smallest possible configuration for Jenkins Configuration as Code plugin"

This gives this message on the welcome screen when Jenkins boots up:

Example of configuration

For more advanced examples take a look at the demos sections found in the official repository for Configuration as Code plugin repository

Example using Docker Compose and Docker secrets

We have a running example using Docker compose you're free to take a look at located here.

Docker image versioning strategy

The tag latest always refer to an image build from HEAD on master. When we do an official release we create a tag corresponding to the version of the included plugin. For instance, at the time of this writing the latest version of the plugin is 0.2-alpha when the Docker image for this version is ready we'll release a version with the tag praqma/jenkins4casc:0.2-alpha and praqma/jenkins4casc:0.2-alpha-latest.

If we need to update the Docker image, with a change that is not related to a new version of the plugin we'll create a new version with the tag 0.2-alpha-1and update the tag praqma/jenkins4casc:0.2-alpha-latest.

Docker autobuild

To create a new docker image on Docker hub, simply tag your commit with a version tag as described above, try to match the version with the version of the included Configuration As Code plugin. So for instance if you create a tag: 0.7-alpha and push your change to github, you'll get a docker image with the label: jenkins4casc:0.7-alpha which is what you want.

The repository is setup with Docker autobuild enabled. We build all tags, and master is always built and made available as latest. Versioning is based on the convention described in the Docker image versioning strategy section above.

For more information about how Docker Hub autobuild works please consult the official guide.

jenkins4casc's People

Contributors

ewelinawilkosz avatar madsnielsen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jenkins4casc's Issues

Configure autobuilds on docker hub

Should build latest, should build tagged versions and tag them with the version mentioned by the tag.

Describe our release process in the readme, saying we release version by tagging.

unable to start jenkins though I have required config file under /var/jenkins_home/casc_configs

Aug 22, 2019 1:43:41 AM hudson.ExtensionFinder$GuiceFinder$SezpozModule configure
WARNING: Failed to load io.jenkins.plugins.casc.support.credentials.DirectEntryPrivateKeySourceConfigurator
java.lang.LinkageError: Failed to resolve class io.jenkins.plugins.casc.support.credentials.DirectEntryPrivateKeySourceConfigurator
at hudson.ExtensionFinder$GuiceFinder$SezpozModule.resolve(ExtensionFinder.java:507)
at hudson.ExtensionFinder$GuiceFinder$SezpozModule.configure(ExtensionFinder.java:527)
at com.google.inject.AbstractModule.configure(AbstractModule.java:62)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
at com.google.inject.spi.Elements.getElements(Elements.java:110)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at hudson.ExtensionFinder$GuiceFinder.(ExtensionFinder.java:285)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at net.java.sezpoz.IndexItem.instance(IndexItem.java:181)
at hudson.ExtensionFinder$Sezpoz._find(ExtensionFinder.java:715)
at hudson.ExtensionFinder$Sezpoz.find(ExtensionFinder.java:690)
at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:494)
at hudson.ExtensionList.load(ExtensionList.java:380)
at hudson.ExtensionList.ensureLoaded(ExtensionList.java:318)
at hudson.ExtensionList.getComponents(ExtensionList.java:183)
at jenkins.model.Jenkins$6.onInitMilestoneAttained(Jenkins.java:1114)
at jenkins.InitReactorRunner$1.onAttained(InitReactorRunner.java:83)
at org.jvnet.hudson.reactor.ReactorListener$Aggregator.lambda$onAttained$3(ReactorListener.java:102)
at org.jvnet.hudson.reactor.ReactorListener$Aggregator.run(ReactorListener.java:109)
at org.jvnet.hudson.reactor.ReactorListener$Aggregator.onAttained(ReactorListener.java:102)
at org.jvnet.hudson.reactor.Reactor$1.run(Reactor.java:177)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.TypeNotPresentException: Type com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource not present
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:90)
at java.lang.Class.getGenericSuperclass(Class.java:777)
at hudson.ExtensionFinder$GuiceFinder$SezpozModule.resolve(ExtensionFinder.java:488)
... 31 more
Caused by: java.lang.ClassNotFoundException: com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$DirectEntryPrivateKeySource
at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1374)
at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1327)
at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1080)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
... 39 more

Aug 22, 2019 1:43:41 AM jenkins.InitReactorRunner$1 onAttained
INFO: Prepared all plugins
Aug 22, 2019 1:43:41 AM jenkins.InitReactorRunner$1 onAttained
INFO: Started all plugins
Aug 22, 2019 1:43:41 AM jenkins.InitReactorRunner$1 onAttained
INFO: Augmented all extensions
Aug 22, 2019 1:43:41 AM jenkins.InitReactorRunner$1 onTaskFailed
SEVERE: Failed ConfigurationAsCode.init
java.lang.Error: java.lang.reflect.InvocationTargetException
at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins$5.runTask(Jenkins.java:1083)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
... 8 more
Caused by: io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration: '/var/jenkins_home/casc_configs/jenkins.yaml' isn't a valid path.
at io.jenkins.plugins.casc.ConfigurationAsCode.configs(ConfigurationAsCode.java:572)
at io.jenkins.plugins.casc.ConfigurationAsCode.getStandardConfigSources(ConfigurationAsCode.java:285)
at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:275)
at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:267)
... 13 more

Aug 22, 2019 1:43:41 AM hudson.util.BootFailure publish
SEVERE: Failed to initialize Jenkins
hudson.util.HudsonFailedToLoad: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
at hudson.WebAppMain$3.run(WebAppMain.java:250)
Caused by: org.jvnet.hudson.reactor.ReactorException: java.lang.Error: java.lang.reflect.InvocationTargetException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:48)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1117)
at jenkins.model.Jenkins.(Jenkins.java:921)
at hudson.model.Hudson.(Hudson.java:85)
at hudson.model.Hudson.(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:233)
Caused by: java.lang.Error: java.lang.reflect.InvocationTargetException
at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins$5.runTask(Jenkins.java:1083)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
... 8 more
Caused by: io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration: '/var/jenkins_home/casc_configs/jenkins.yaml' isn't a valid path.
at io.jenkins.plugins.casc.ConfigurationAsCode.configs(ConfigurationAsCode.java:572)
at io.jenkins.plugins.casc.ConfigurationAsCode.getStandardConfigSources(ConfigurationAsCode.java:285)
at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:275)
at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:267)
... 13 more

Aug 22, 2019 1:43:42 AM jenkins.model.Jenkins cleanUp
INFO: Stopping Jenkins
Aug 22, 2019 1:43:42 AM jenkins.model.Jenkins$18 onAttained
INFO: Started termination
Aug 22, 2019 1:43:42 AM jenkins.model.Jenkins$18 onAttained
INFO: Completed termination
Aug 22, 2019 1:43:42 AM jenkins.model.Jenkins _cleanUpDisconnectComputers
INFO: Starting node disconnection
Aug 22, 2019 1:43:42 AM jenkins.model.Jenkins _cleanUpShutdownPluginManager
INFO: Stopping plugin manager
Aug 22, 2019 1:43:42 AM jenkins.model.Jenkins _cleanUpPersistQueue
INFO: Persisting build queue
Aug 22, 2019 1:43:42 AM jenkins.model.Jenkins _cleanUpAwaitDisconnects
INFO: Waiting for node disconnection completion
Aug 22, 2019 1:43:42 AM jenkins.model.Jenkins cleanUp
INFO: Jenkins stopped

Add readme

Describing what this repository is for, how to use it... it will be public on our docker hub so it should be nice.

Later we will link to some overall documentation about the demo instance.

Automate the process to bump to the latest version of c-as-c

Currently it is a manual task to edit, commit and tag with the correct version when there is a new release of c-as-c. We want to automate the process that:

  1. Discovers the latest version of the Jenkins Configuration as Code plugin
  2. Edits the required files in the repository with this version
  3. Commits and tags with the appropriate release tag.

Create Dockerfile

##- [x] Bases on default Jenkins docker hub image

  • should not run startup guide with plugin installation and admin secrets
  • should handle plugin installation, for now using install-plugins.sh, later we will move to casc to handle it (#4)
  • ~~~* should obviously install our Jenkins configuration as code plugin from most recent version publicly available in update center~~~ See #5

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.