Jenkins Docker-plugin and Kubernetes-plugin plug-in practical case

Source: Internet
Author: User
Tags jenkins docker k8s

How to use Jenkins docker-plugin:
Node {stage (' Clone Code ') {dir (' baas-ops ') {git credentialsid: ' Umarkci ',                URL: ' [Email protected]******.com:umark/baas-ops.git '}} stage (' Unit testing ') {                Docker.image (' BusyBox '). Inside {sh ' echo "Unit testing step!!!" ' }} stage (' Build ') {docker.image (' BusyBox '). Inside {sh ' echo Build                Step!!! ' }} stage (' Image Build and Push ') {dir (' baas-ops/oboe/cli ') {Docker.wit Hregistry (' https://registry.******.com:8080 ', ' registry-hub-credentials ') {docker.build (' O Boe-cli '). push (' T1 ')}}} stage (' Deploy images ') {TR y {sh ' docker rm-f test '} catch (e) {} docker.image (' oboe-Cli:t1 '). Run ('-p 80:3000--name test ')}} 
Jenkins Kubernetes-plugin Plugin uses:
Podtemplate (Label: ' Test ', SecurityContext: [runasuser: ' Root '], containers: [Containertemplate (Name: ' JNLP ', Image: ' Registry.******.com:8088/jnlp-slave:alpine ', args: ' ${computer.jnlpmac} ${computer.name} '), ContainerTempla TE (name: ' Docker ', Image: ' Docker:stable ', ttyenabled:true, command: ' Cat ')], volumes: [HOSTPATHVO Lume (hostpath: '/var/run/docker.sock ', Mountpath: '/var/run/docker.sock '),//Hostpathvolume (hostpath: '/tmp/test ', Mountpath: '/data '), Persistentvolumeclaim (claimname: ' Jenkins-slave-gfs ', Mountpath: '/home/jenkins ', ReadO Nly:false)] {node (' Test ') {def registryaddr= ' registry.******.com:8080 ' stage (' Build imag                E ') {git credentialsid: ' oschina-test ', url: ' [email protected]:yonchin/jenkins-test.git '                Container (' docker ') {sh ' docker build-t ${registryaddr}/busybox:k8s. " }} stage (' Push IMage ') {container (' Docker ') {withcredentials ([Usernamepassword (credentialsid: ' Reg                                Istry-hub-credentials ', passwordvariable: ' Registrypass ', usernamevariable: ' Registryuser ')]) {  SH "Docker login ${registryaddr}-u ${env.registryuser}-P ${registrypass}" sh "docker Push ${registryaddr}/busybox:k8s "}}}" Note: Where Credentialsid is going to be in Jenkins Credentials, System-I, Global credentials (unrestricted), ADD credentials is created in advance. Where, Registryuser and registrypass These two variables are automatically obtained in ' ADD credentials ' defined to the user name and password.

Jenkins Docker-plugin and Kubernetes-plugin plug-in practical case

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.