docker-compose

  1. version: "3"
  2. services:
  3. jenkins:
  4. container_name: jenkins
  5. image: jenkinsci/blueocean
  6. ports:
  7. - "8080:8080"

登录

jenkins 默认登录用户为 admin,初始密码存放在/data/secrets/initialAdminPassword 下

jenkins 修改系统语言

  1. Download and install the local plugin:
    1. From the main page of Jenkins, go to Manage Jenkins -> Manage Plugins
    2. Click on Availables
    3. Check the “Locale plugin” and clicks on “Download now and install after restart”

Jenkins will download the plugin and restart if not job has been scheduled

  1. Set the language
    1. From the main page of Jenkins, go to Manage Jenkins -> Configure System
    2. Under Locale, there will be a field called “Default Language”. Enter the new language. It could be “en” or “ENGLISH”
    3. Under the text box, check the checkBox called “Ignore browser preference and force this language to all users”

pipeline stage view install

  1. Download and install the pipline stage view plugin:
    1. From the main page of Jenkins,go to Mange Jenkins -> Manage Plugins
    2. Click on Availables
    3. Check the “Pipeline Stage View Plugin” and clicks on “Download now and install after restart”

Jenkins will download the plugin and restart if not job has been scheduled

  1. 检查 pipeline stage view 插件是否安装成功

    1. Jenkins 创建一个 pipeline 项目
    2. 将以下配置放到 pipeline script 里 ```groovy pipeline { agent any

    stages { stage(‘Build’) {

    1. steps {
    2. echo 'Building...'
    3. echo "Running ${env.BUILD_ID} ${env.BUILD_DISPLAY_NAME} on ${env.NODE_NAME} and JOB ${env.JOB_NAME}"
    4. }

    } stage(‘Test’) { steps {

    1. echo 'Testing...'

    } } stage(‘Deploy’) { steps {

    1. echo 'Deploying...'

    } } } } ``` image.png

    1. 保存配置
    2. build now 并查看是否有 pipeline stage view 页面

image.png

pipeline script from SCM

  1. 创建一个pipeline项目
  2. 配置pipeline script位置
    1. 跳转到 pipeline 配置,Definition 选择 Pipeline script from SCM
    2. 填写相应信息(注意 jenkinsfile 的 path 要写对)
  3. 保存配置
  4. build now

结果与上面的 pipeline script 相同,但第一步多了一个 Declarative: Checkout SCM 的步骤