版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_41819299/article/details/83304933
1.简介
可靠和可重复的自动化工具,将多个任务连接起来连续执行,可扩展性强
2.定义
持续交付(CD)流水线
Jenkinsfile:声明式pipeline、脚本式pipeline
3.声明式pipeline
Jenkinsfile (Declarative Pipeline)
pipeline {
agent any //在任何可用的代理上执行这个 Pipeline 或其任意 stage
stages {
stage('Build') { //定义 "Build" stage
steps {
// 执行和 "Build" stage 相关的 step
}
}
stage('Test') { // 定义 "Test" stage
steps {
// 执行和 "Test" stage 相关的 step
}
}
stage('Deploy') {
steps {
//
}
}
}
}
4.脚本式pipeline
5.构建
参考链接:https://blog.csdn.net/wh211212/article/details/77482138
GitHub project/Project url 是pipeline所用的git链接
流水线 Repository URL是 Jenkinsfile的地址,用git的配置如下:
脚本路径是声明式/脚本式pipeline在URL中的地址
6.踩过的坑
1。控制端在一开始就公钥报错:
hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/master:refs/remotes/origin/master --prune" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
可能是新换了设备或用户,导致的权限问题
>git config --list 查看user.name和user.email是否正确并修改
>将jenkins的公钥添加到用户的git中
ssh-keygen
cat ~/.ssh/id_rsa.pub