Get start with Docker & DevOps Sr.Analyst Oksana Dudnik
Lets start with Docker ToolBox At first we must install Docker ToolBox on local computer: Go to the Docker Toolbox page.Docker Toolbox Download and install (close all another programs).
Lets create docker-machine In FAR or in Git CMD(run as administrator) : >docker-machine create –driver virtualbox –virtualbox-memory 4096 default If there now errors: >docker-machine create –driver virtualbox –virtualbox-memory 4096 adop >docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS adop * virtualbox Running tcp:// :2376 v default - virtualbox Running tcp:// :2376 v1.10.3
CREATE environment variables >SETX DOCKER_MACHINE_NAME adop >SETX DOCKER_HOST tcp:// :2376 >SETX DOCKER_CERT_PATH C:\Users\oksana.dudnik\.docker\machine\machines\adop >SETX DOCKER_TLS_VERYFY 1
setx LDAP_PWD "Jpk66g63ZifGYIcShSGM setx LDAP_DOMAIN "ldap.example.com setx LDAP_FULL_DOMAIN "dc=ldap,dc=example,dc=com setx GERRIT_MYSQL_USER "gerrit setx GERRIT_MYSQL_PASSWORD "gerrit setx GERRIT_MYSQL_DATABASE "gerrit setx GERRIT_USER_NAME "Gerrit Code Review" setx GERRIT_USER_ setx SONAR_MYSQL_USER "sonar setx SONAR_MYSQL_PASSWORD "sonar setx SONAR_MYSQL_DATABASE "sonar setx SONAR_ACCOUNT_LOGIN "jenkins setx SONAR_ACCOUNT_PASSWORD "jenkins setx SONAR_DB_LOGIN "%SONAR_MYSQL_USER% setx SONAR_DB_PASSWORD "%SONAR_MYSQL_PASSWORD% setx DOCKER_CLIENT_CERT_PATH //root/.docker/
Received environment variables CERT_PATH=$0 //root/.docker/ CLIENT_SUBJ=/CN=client CUSTOM_NETWORK_NAME=adopnetwork DOCKER_CERT_PATH=C:\Users\oksana.dudnik\.docker\machine\machines\adop DOCKER_CLIENT_CERT_PATH=//root/.docker/ DOCKER_HOST=tcp:// :2376 DOCKER_MACHINE_NAME=adop DOCKER_TLS_VERIFY=1 DOCKER_TOOLBOX_INSTALL_PATH=C:\Program Files\Docker Toolbox
Envorment variables GERRIT_MYSQL_DATABASE=gerrit GERRIT_MYSQL_PASSWORD=gerrit GERRIT_MYSQL_USER=gerrit GERRIT_USER_NAME=Gerrit Code Review HOME=/root HOMEDRIVE=C: HOMEPATH=\Users\oksana.dudnik HOST= LDAP_DOMAIN=ldap.example.com LDAP_FULL_DOMAIN=dc=ldap,dc=example,dc=com LDAP_PWD=Jpk66g63ZifGYIcShSGM
Envorment variables LOGSTASH_HOST= MACHINE_NAME=adop SONAR_ACCOUNT_LOGIN=jenkins SONAR_ACCOUNT_PASSWORD=jenkins SONAR_DB_LOGIN=sonar SONAR_DB_PASSWORD=sonar SONAR_MYSQL_DATABASE=sonar SONAR_MYSQL_PASSWORD=sonar SONAR_MYSQL_USER=sonar USER_HOME=C:\Users\oksana.dudnik VOLUM_DRIVER=local
CREATE network setx TARGET_HOST " setx LOGSTASH_HOST %TARGET_HOST%" docker network create %CUSTOM_NETWORK_NAME%
Start docker-compose docker-compose -f compose/elk.yml pull docker-compose -f docker-compose.yml -f etc/volumes/local/default.yml -f etc/logging/syslog/default.yml pull docker-compose pull docker-compose -f compose/elk.yml up -d docker-compose -f docker-compose.yml -f etc/volumes/local/default.yml -f etc/logging/syslog/default.yml up -d
Run docker container jenkins >docker exec jenkins curl -I -s >docker exec jenkins curl -X POST WithParameters --data token=gAsuE35s
GENERATE ssl certificates This command you must run from Git CMD as administrator Or from program Kitematic -> PowerShell (from DockerToolBox) >generate_client_certs.sh ${DOCKER_CLIENT_CERT_PATH}
Lets go to docker-host: Access the target host url with the user john.smith and password Password01
Success!
Prepared project PetClinic /jenkins/job/LoadPlatform - rebuild All downstream jobs /jenkins/job/ExampleWorkspace/job/Exa mpleProject/job/Create_Environment Click Build with parameters /jenkins/job/ExampleWorkspace/job/Exa mpleProject/view/Java_Reference_Application/ Click Run
Success build and deploy!
Click on link Console Output
Click on Environment URL
Click on link #1Reference_Application_Deploy
Get Result!
Lets create own example Our tasks: Create new job for Jenkins for build project from GIT-repository Create shell script for setup tomcat-service Create new job for Jenkins for deploy this project with service tomcat Create view for review our jobs
Lets install Jenkins Job DSL plugin
Lets check if installed
Lets create freestyle initial job which will be generate another jobs : tomcat setup, build, deploy
Click add Item:
Lets create freestyle initial job which will be generate another jobs : tomcat setup, build, deploy
Lets add step during build Process Job DSLs:
Lets create groovy - script for job /java201-adop-cartidge.git //dls_generate_jobs.groovy def PROJECT_NAME="Master_Build" def WORKSPACE_NAME="Master_Build" // Folders def workspaceFolderName = "${WORKSPACE_NAME}" def projectFolderName = "${PROJECT_NAME}" // Variables def referenceAppGitRepo = "master" def referenceAppGitUrl = "
Lets see dsl_generate_job.groovy // Jobs def buildAppJob = freeStyleJob("Master_Build") buildAppJob.with { description("This job builds Master application") wrappers { preBuildCleanup() injectPasswords() maskPasswords() sshAgent("adop-jenkins-master") } scm { git { remote { url(referenceAppGitUrl) credentials("adop-jenkins-master") } branch("*/master") } } environmentVariables { env('WORKSPACE_NAME',workspaceFolderName) env('PROJECT_NAME',projectFolderName) env("ENVIRONMENT_NAME",'CI') } label("java8") triggers{ gerrit{ events{ refUpdated() } configure { gerritxml -> gerritxml / 'gerritProjects' { 'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject' { compareType("PLAIN") pattern(referenceAppGitRepo) 'branches' { 'com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch' { compareType("PLAIN") pattern("master") } } } } gerritxml / serverName("ADOP Gerrit") } } } steps { maven{ goals('clean install -DskipTests') mavenInstallation("maven") } } publishers{ archiveArtifacts("**/*") } } queue("Master_Build")
Creating view: // Views def pipelineView = buildPipelineView("Master_Application") pipelineView.with{ title('Master_Application Pipeline') displayedBuilds(5) selectedJob("Master_Build") showPipelineParameters() showPipelineDefinitionHeader() refreshFrequency(5) } queue("Master_Application")
Result:
Created view Master_Application
Click Master_Application tab:
Lets add downstream-projects to view:
Lets add new listview with button Build
Groovy script for this you will find in repository: cartidge.git cartidge.git
References basics-tldr.html basics-tldr.html basics.html basics.html 3.html 3.html adding-new-commands.html adding-new-commands.html