首先 我们需要 单独自定义一个 agent
参考步骤
kubesphere 流水线自定义 Jenkins Agent :连接
kubeshphere 流水线 agent 自定义 如何使用 : 连接
2- 设置
把这个container 加入到 contaners 中
- name: "centos79"
image: "registry.cn-hangzhou.aliyuncs.com/baimeidashu-k8s/centos79:v2"
可以直接添加到 官方自定义的中,
也可以 自己再重新定义一个,名字不同就可以。
白眉用的这个:
- name: "mavenjdk17gradle74"
label: "jdk17gradle74-1"
inheritFrom: "maven"
containers:
- name: "maven"
image: "registry.cn-hangzhou.aliyuncs.com/baimeidashu/jdk17gradle74:v5"
- name: "centos79"
image: "registry.cn-hangzhou.aliyuncs.com/baimeidashu-k8s/centos79:v2"
3- 测试流水线:
pipeline {
agent {
node {
label 'maven-centos7'
}
}
stages {
stage('拉取代码 阶段') {
agent none
steps {
container('maven') {
git(url: 'https://gitee.com/wang-huamao/springboot-demo-k8s.git', credentialsId: 'codeup-token', branch: 'master', changelog: true, poll: false)
}
}
}
stage('curl 阶段 ') {
agent none
steps {
container('centos79') {
sh '''
curl \'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6e82e102-641b-41d9-a179-e6795ff0c8d6\' -H \'Content-Type: application/json\' -d \'{"msgtype": "text","text": {"content": "hello world 发布成功 '$APP_NAME' ", "mentioned_list": ["zhaozhiyong","@all"]}}\'
'''
}
}
}
}
environment {
DOCKER_CREDENTIAL_ID = 'dockerhub-id'
GITHUB_CREDENTIAL_ID = 'github-id'
KUBECONFIG_CREDENTIAL_ID = 'demo-kubeconfig'
REGISTRY = 'registry.cn-hangzhou.aliyuncs.com'
DOCKERHUB_NAMESPACE = 'baimeidashu-k8s'
ALIYUNHUB_NAMESPACE = 'baimeidashu-k8s'
GITHUB_ACCOUNT = 'kubesphere'
APP_NAME = 'springboot-demo-k8s'
}
}
欢迎来撩 : 汇总all