设计网站推荐语,做网站公司哪家正规,免费关键词排名优化软件,作品展示的网站在pinline克隆代码的两种方式 1.pipline语法直接实现方式1.1例子11.2例子2 2.jenkins pinline 流水线中调用 shell脚本方式 jenkins搭建流水线从拉取代码开始其实是最正规的方式#xff0c;但是如何拉取有多种方式 可以用jenkins的插件以钩子的形式#xff0c;也可以在piplin… 在pinline克隆代码的两种方式 1.pipline语法直接实现方式1.1例子11.2例子2 2.jenkins pinline 流水线中调用 shell脚本方式 jenkins搭建流水线从拉取代码开始其实是最正规的方式但是如何拉取有多种方式 可以用jenkins的插件以钩子的形式也可以在pipline脚本中实现今天介绍两种 pipline方式实现拉取代码的方式。 1.pipline语法直接实现方式
1.1例子1
pipeline {agent anystages {stage(Project1){steps{cleanWs()dir(project1) {// Doing your project 1 stuffgit(url: https://github.com/xxx/proj1.git, branch: main)}}}stage(Project 2){steps{dir(project2) {// Doing your project 2 stuffgit(url: https://github.com/xxx/proj2.git, branch: dev)}}}stage(Something Else){steps{sh ls -al }}}
}1.2例子2
pipeline {agent anystages {stage(Project1){steps{cleanWs()echo Lets move proj 1 stuff to a sub dirsh mkdir project1shopt -s extglob dotglobmv !(project1) project1}}stage(Project 2){steps{dir(project2) {// Doing your project 2 stuffgit(url: https://github.com/xxx/proj2.git, branch: main)}}}stage(Something Else){steps{sh ls -al }}}
}2.jenkins pinline 流水线中调用 shell脚本方式
这种方式需要服务器预先安装好了git
pipline中调用shell脚本
def CustomizeRepos
def Baseline false
def VersionInfo
def testMessage
def Pr_CustomizeRepos pipeline {agent {label le-node}parameters {string(name: BRANCHNAME, defaultValue: develop, description: 代码分支名称)}environment {JENKINS_NODE_COOKIE dontKillMeproject_path /automation/code/pipeline_git_tool /automation/scripts/build_gitclone.shurl https://gitee.com/burebaobao/tscancode-master.git}stage(下载平台代码) {steps {script {echo 开始克隆代码sh cd ${project_path}// 调用脚本sh ${env.pipeline_git_tool} ${project_path} ${BRANCHNAME} ${url}}}}}所调用的shell脚本
#!/bin/bash#########################################
#代码clone脚本
#参数
# path 代码存储路径
# branch 代码分支名
# url 地址
##########################################参数判断
if [ $# ! 3 ]; thenecho 参数输入错误,输入必须包括path、Branch、url参数!exit -1
fipath$1
branch$2
url$3echo 开始
echo 切换路径到 $path
cd ${path}echo 克隆的代码分支为 ${branch}mcdgit clone -b ${branch} --single-branch https://gitee.com/burebaobao/tscancode-master.git
git clone -b ${branch} --single-branch ${url}