Git Product home page Git Product logo

cirulls / hands-on-jenkins Goto Github PK

View Code? Open in Web Editor NEW
70.0 7.0 617.0 20.36 MB

Companion code, slides and exercises of the video course Hands-on Continuous Integration and Automation with Jenkins by Packt Publishing

License: GNU General Public License v3.0

Shell 31.23% Batchfile 0.40% Groovy 32.14% Python 23.38% HTML 7.30% Dockerfile 5.55%
jenkins continuous-integration continuous-delivery automation video-course

hands-on-jenkins's Introduction

Hands-on Continuous Integration and Automation with Jenkins

This repository contains the companion code, slides, exercises and solutions for the video course Hands-on Continuous Integration and Automation with Jenkins by Packt Publishing (to be published in 2018).

Interact and Contribute

If you wish to ask a question, share an alternative solution to the exercises, raise a bug in the code or in the videos, or simply provide a feedback, feel free to use the issue tracker so that it can be visible and useful for anyone following the course.

hands-on-jenkins's People

Contributors

andrei-dascalu avatar cirulls avatar dependabot[bot] 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

hands-on-jenkins's Issues

Jenkinsfiles

Hi Cirulls,

I have just started working through your training videos and the course is great so far. I think i will have more confidence by the time i finish the training, but i am getting error message when i run the pipeline.

curl --user admin:admin -X POST -F "jenkinsfile=<Jenkinsfile" http://192.168.25.137:8080/pipeline-model-converter/validate
Errors encountered validating Jenkinsfile:
WorkflowScript: 25: Step does not take a single required parameter - use named parameters instead @ line 25, column 21.
steps { deploy('dev') }
^

WorkflowScript: 33: Step does not take a single required parameter - use named parameters instead @ line 33, column 21.
steps { deploy('stage') }
^

WorkflowScript: 45: Step does not take a single required parameter - use named parameters instead @ line 45, column 21.
steps { deploy('live') }

my version of jenkins is 2.190

As i am new to jenkins and using pipelines i am not sure how to edit the file to set named parameters to get rig of this error.

Can you help please?
Regards,
Vince bailey

CD Pipeline build & deploy to dev fails

When doing the CD Pipeline build in video 4.5 the Jenkinsfile_part_1 does not build properly.

Started by user Krasimir Karov
Obtained section_4/code/cd_pipeline/Jenkinsfile_part_1 from git https://github.com/cirulls/hands-on-jenkins
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/cd_pipeline
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
The recommended git tool is: git
No credentials specified

git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/cirulls/hands-on-jenkins # timeout=10
Fetching upstream changes from https://github.com/cirulls/hands-on-jenkins
git --version # timeout=10
git --version # 'git version 2.25.1'
git fetch --tags --force --progress -- https://github.com/cirulls/hands-on-jenkins +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 2e00f71 (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git read-tree -mu HEAD # timeout=10
git checkout -f 2e00f71 # timeout=10
Commit message: "Upgrade Flask to v1.0.2 (#18)"
git rev-list --no-walk 2e00f71 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/cd_pipeline/section_4/code/cd_pipeline
[Pipeline] {
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy - Dev)
Stage "Deploy - Dev" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
groovy.lang.MissingPropertyException: No such property: docker for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:270)
at org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:353)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:357)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:333)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.buildApp(WorkflowScript:27)
at cps.transform(Native Method)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
at sun.reflect.GeneratedMethodAccessor376.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:400)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:96)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:312)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:276)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:136)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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)
Finished: FAILURE

Maybe I missed something in the videos, but I can't seem to get it running.

Maven missing from docker container

The docker container does not include maven. The instructions in the video merely say

Before we get started with this video, make sure you have the following things set up, as we will not cover them during the demo. You may already have maven installed on your machine, but if not, the easiest way to install it is via Jenkins, by navigating to Manage Jenkins, Global Tool Configuration, Maven, and add the maven installation. Alternatively, you might want to install maven via your operating system.

I followed those instruction for installing maven via Jenkins adding the default installer (install from Apache), assuming that either maven must be a tool which could be installed by just unpacking files into an area in the file system to which the process/account running Jenkins had write access, or that Jenkins was running as root (a very unappealing thought). I was able to install maven by getting a root shell in the docker container (docker exec -it -u root ...) but the instructions as given in the video need to be adjusted. If it is indeed possible to install maven on the server from the Jenkins web interface, please provide more explicit instructions. Otherwise, explain the steps needed to get maven installed in the docker container without the assistance of Jenkins.

missing solution files

IN hands-on-jenkins/section_4/exercises/solutions.md it references to 4 files but they don't exist. Can you add those?

The text looks like this:
Practice
See the following files:

app.py
Jenkinsfile
test_flask_app.py
Jenkinsfile

Jenkins in a container "docker: not found"

First of all, good quality stuff, Sandro.

I run ubuntu host with Docker installed. As instructed in practical exercise I download Jenkins container image and run Jenkins from the container. It's all dandy but in chapter 4 when we need to build new images with docker build from Pipeline - Jenkins is not aware of any docker to build images

  • docker build -t hands-on-jenkins/myapp:1 .
    /var/jenkins_home/workspace/proper-pipeline/section_4/code/cd_pipeline@tmp/durable-976ce4eb/script.sh: 1: /var/jenkins_home/workspace/proper-pipeline/section_4/code/cd_pipeline@tmp/durable-976ce4eb/script.sh: docker: not found

I created Jenkins container with "-v /var/run/docker.sock:/var/run/docker.sock" but that does not seam to help. As I understand installing docker inside Jenkins container - docker in docker is not a good approach either. So how can Jenkins in a container interact with my Ubuntu (host) Docker?
Am I missing something? Thanks for any tip.

Installing Jenkins on Docker

Hello Sandro,

I followed your provided steps to install jenkins on docker. But when i access localhost:8080 and after I add the temporary admin password I get the message "This Jenkins instance appears to be offline." checking over google i get to know that my docker contain is not having the internet access (may be)

Can you help me resolve it?

lab setup:

  1. I am using win10
  2. Create a VM with centos in VMware workstation
  3. Installed docker on it
  4. Pull and run the jenkins/jenkins:lts

image

Error from Jenkinsfiles_part_1

Hi Sandro,

When I build the pipeline using section_4/code/cd_pipleline/Jenkinsfiles_part_1, I get the following error. Please advise.

  • docker ps -f name=app_dev -q
  • xargs --no-run-if-empty docker stop
    xargs: illegal option -- -
    usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
    [-L number] [-n number [-x]] [-P maxprocs] [-s size]
    [utility [argument ...]]

Thanks,
Azher

Example with Docker-Compose

Hi, I have the next question, its possible add docker-compose in jenkins pipelines using jenkins container? how add docker-compose to jenkins container ? I try passing with volume similar to link docker.sock but i cant get the command docker-compose inside of my container.

PD: I learned much with packpub course and now i try to integrate jenkins in my projects hehehe

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.