Jenkins與Docker相關的Plugin使用

##Jenkins與Docker相關的Plugin使用## ###Jenkins與Docker相關的Plugin### 在Jenkins Plugin頁面搜索與Docker相關的插件,有以下幾個:docker

  • CloudBees Docker Build and Publish plugin — This plugin provides the ability to build projects with a Dockerfile, and publish the resultant tagged image (repo) to the docker registry.
  • Docker build step plugin — This plugin allows to add various Docker commands into you job as a build step.
  • Docker Plugin — This plugin allows slaves to be dynamically provisioned using Docker.
  • Kubernetes Plugin — This plugin allows slaves to be dynamically provisioned on multiple Docker hosts using Kubernetes.
  • Docker Commons Plugin — APIs for using Docker from other plugins.

其中,它們間的關係以下:ide

  • Docker commons Plugin爲其餘與Docker相關的插件提供了APIs
  • CloudBees Docker Build and Publish plugin和Docker build step plugin都依賴了Docker commons Plugin
  • Kubernetes Plugin依賴了Docker Plugin

下面主要介紹下Docker build step plugin和CloudBees Docker Build and Publish plugin的使用。測試

###Docker build step plugin使用###ui

####設置Docker URL#### 系統管理→系統設置→Docker Builder,設置Docker URL並測試鏈接。插件

docker-build-step

####在Jenkins JOB的構建區域,增長構建步驟→Execute Docker container#### 有一系列Docker Command可選擇日誌

docker-build-step

docker-build-step

####以重啓一個容器爲例#### 選擇Restart containers命令,並填寫Container ID(s):ip

docker-build-step

Jenkins JOB建立成功後,點擊構建,日誌輸出以下:ci

docker-build-step

####以Push鏡像到Docker registry爲例#### 選擇Push images命令,並填寫相關信息:get

docker-build-step

Jenkins JOB建立成功後,點擊構建,日誌輸出以下:源碼

docker-build-step

###Docker Build Publish Plugin使用###

####設置源碼地址,這裏使用的是GIT@OSC#### 該項目是個Docker化的項目,Dockerfile在根目錄下

docker-build-publish

####在Jenkins JOB的構建區域,增長構建步驟→Docker Build and Publish#### docker-build-publish

此外,Docker Build Publish Plugin還要一些高級選項

docker-build-publish

####Jenkins JOB建立成功後,點擊構建,日誌輸出以下#### docker-build-publish

###參考###

相關文章
相關標籤/搜索