1.创建pipeline job任务,新建任务》输入任务名称》选择“流水线”》点击【确定】

添加描述,This is my first test pipeline job

添加 pipeline脚本,点击【保存】

脚本解释

1. 声明脚本,添加环境变量

2.添加选项参数deploy_env,以及文本参数version

3.新建stage任务,将定义deploy_env、version参数,传入到test.properties 中

4.检查test.properties是否存在内容

5.完整脚本

#!groovy

pipeline {
agent {node {label 'master'}} environment {
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
} parameters {
choice(
choices: 'dev\nprod',
description: 'choose deploy environment',
name: 'deploy_env'
)
string (name: 'version', defaultValue: '1.0.0', description: 'build version')
} stages {
stage("Checkout test repo") {
steps{
sh 'git config --global http.sslVerify false'
dir ("${env.WORKSPACE}") {
git branch: 'master', credentialsId:"9aa11671-aab9-47c7-a5e1-a4be146bd587", url: 'https://root@gitlab.example.com/root/test-repo.git'
}
}
}
stage("Print env variable") {
steps {
dir ("${env.WORKSPACE}") {
sh """
echo "[INFO] Print env variable"
echo "Current deployment environment is $deploy_env" >> test.properties
echo "The build is $version" >> test.properties
echo "[INFO] Done..."
"""
}
}
}
stage("Check test properties") {
steps{
dir ("${env.WORKSPACE}") {
sh """
echo "[INFO] Check test properties"
if [ -s test.properties ]
then
cat test.properties
echo "[INFO] Done..."
else
echo "test.properties is empty"
fi
""" echo "[INFO] Build finished..."
}
}
}
}
}

控制台输出

Jenkins Pipeline Job构建配置的更多相关文章

  1. Jenkins+pipeline+参数构建+人工干预确定

    Jenkins+pipeline+参数构建+人工干预 实现了以下功能 1. 可以选择环境,单选:可以选择需要发布的项目,多选 2.发布过程可视化 3. 可以人工干预是否继续发布. 初始化配置需要很久, ...

  2. Jenkins Pipeline+sonar构建质量平台

    前提: Jenkins JDK 目录: 1.安装sonar插件:SonarQube Scanner for Jenkins 2.安装SonarQube 3.安装sonar-scanner ++++++ ...

  3. 使用Jenkins pipeline流水线构建docker镜像和发布

    新建一个pipeline job 选择Pipeline任务,然后进入配置页面. 对于Pipeline, Definition选择 "Pipeline script from SCM" ...

  4. Jenkins + Pipeline 构建流水线发布

      Jenkins + Pipeline 构建流水线发布 利用Jenkins的Pipeline配置发布流水线 参考: https://jenkins.io/doc/pipeline/tour/depl ...

  5. jenkins pipeline构建后发送邮件通知

    jenkins pipeline构建后发送邮件通知 mail配置 进入系统配置 找到最下边的邮件通知 创建任务 Pipeline片段 post { always { bat "" ...

  6. jenkins pipeline构建后返回构建结果给gitlab

    jenkins pipeline构建后返回构建结果给gitlab 使用场景 gitlab 合并请求时要求管道任务必须成功,否则无法执行合并操作,又不想使用gitlab ci 工具. 实现方法 1.Ge ...

  7. Jenkins自动化构建配置

    写在前头 我每次修改代码一点东西,都要进行一个重新发布.重新发布的流程大概如下: 将最新代码同步上传到git上面 Maven打包 mvn clean install 将最新的jar包上传到服务器上面, ...

  8. jenkins git gradle android自动化构建配置

    需要安装软件(jenkins所在服务器): gradle.SDK 一.gradle安装(服务器部署的gradle版本需要等于或高于开发环境的gradle版本) 1.下载地址:http://servic ...

  9. Jenkins操作学习 --邮箱配置及测试结果构建

    前言 使用jenkins做持续集成工具,构建的整个过程中,肯定要对结果进行记录和跟踪,这里我们以qq邮箱为例,来讲解如何配置jenkins的邮箱及发送构建结果 一.明确邮箱服务器相关信息 这里我们,要 ...

随机推荐

  1. 12174 - Shuffle——[滑动窗口]

    You are listening to your music collection using the shuffle function to keep the music surprising. ...

  2. 【u105】路径计数2

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 一个N×N的网格,你一开始在(1, 1),即左上角.每次只能移动到下方相邻的格子或者右方相邻的格子,问 ...

  3. D Thanking-Bear magic

    题目描述 In order to become a magical girl, Thinking-Bear are learning magic circle. He first drew a reg ...

  4. 2019-3-8-为何使用-DirectComposition

    title author date CreateTime categories 为何使用 DirectComposition lindexi 2019-3-8 8:56:9 +0800 2018-04 ...

  5. Eclipse GlassFish Server 配置

    一.下载GlassFish Server    通过如下地址下载合适版本:    http://glassfish.java.net/public/downloadsindex.html    htt ...

  6. Keras文本预处理

    学习了Keras文档里的文本预处理部分,参考网上代码写了个例子 import keras.preprocessing.text as T from keras.preprocessing.text i ...

  7. npm安装cnpm

    获取npm缓存路径: npm config get cache 离线安装 npm install --cache ./npm-cache --optional --cache-min 99999999 ...

  8. python类型常用整理

    # 一.数字 # int(..) # 二.字符串 # replace find join strip startswith split upper lower format # tempalte = ...

  9. springboot 动态修改定时任务

    1.静态定时 1)启动类加上注解@EnableScheduling @EnableAsync @EnableScheduling @SpringBootApplication @MapperScan( ...

  10. python知识点总结01(不定时更新)

    手写一个完整的装饰器模版 # 用于修复被装饰对象的名称空间 from functools import wrape def wrapper(func): @wraps(func) def inner( ...