Git 詹金斯:推动回购分行&x27;分期付款';到暂存服务器,并分支';生产';到生产服务器
我是詹金斯·努奥比。是否可以/无痛地将这两个yaml文件合并并放置在一个repo中,以便当我推送到分支“暂存”时,Jenkins将其推送到暂存服务器,当我推送到分支“生产”时,Jenkins推送到生产服务器 登台Git 詹金斯:推动回购分行&x27;分期付款';到暂存服务器,并分支';生产';到生产服务器,git,jenkins,Git,Jenkins,我是詹金斯·努奥比。是否可以/无痛地将这两个yaml文件合并并放置在一个repo中,以便当我推送到分支“暂存”时,Jenkins将其推送到暂存服务器,当我推送到分支“生产”时,Jenkins推送到生产服务器 登台 jenkins: project: "Docker Slot StageSlot1 (WestUS)" certbot_url: "https://cert.bots.company.com/" certbot_token: "company-certbot-token"
jenkins:
project: "Docker Slot StageSlot1 (WestUS)"
certbot_url: "https://cert.bots.company.com/"
certbot_token: "company-certbot-token"
domain_file: domain.yaml
docker:
ucp: "tcp://ucp-companydocker.westus.cloudapp.azure.com:443"
dtr: dtr-companydocker.westus.cloudapp.azure.com
ucpid: companyucpdockerwestus
dtrid: jenkinscompanydtrwestus
stackname: COMPANY-SS1-Staging
dockerfile: Dockerfile.build.tmpl
compose: docker-compose-ss1
dtrtag: "/company/stagslot"
ext_port: 8310
ext_https_port: 8311
build_cmd: ""
label: "/Staging/COMPANY/SS1"
cnt: 2
dir_rand: PM25SS1
siteurl: "http://company-ss1-stage.trafficmanager.net"
build_cache: false
slack:
channel: "#webops"
log_errors: false
git:
gitid: company-ss1-id
giturl: "git@github.com:company/company-SS1.git"
gitbranch: staging
生产
jenkins:
project: "Docker Slot ProdSlot1"
certbot_url: "https://cert.bots.company.com/"
certbot_token: "company-certbot-token"
domain_file: domain.yaml
docker:
dockerfile: Dockerfile.build.tmpl
build_cmd: ""
cnt: 4
dir_rand: PM25MS1
siteurl: "http://company-prodslot1.us-west1.gce.companyp.cloud"
build_cache: false
k8s:
gcpid: 'gcp-web-platform'
namespace: 'production'
site: 'ms-01'
env: 'prod'
clusters:
- name: 'gke-web-1'
region: 'us-west1'
slothost: 'company-ms01.us-west1.gce.companyp.cloud'
- name: 'gke-web-2'
region: 'us-central1'
slothost: 'company-ms01.us-central1.gce.companyp.cloud'
slack:
channel: "#webops"
log_errors: false
git:
gitid: company-prodslot1-id
giturl: "git@github.com:company/company-prodslot1.git"
gitbranch: production
欢迎使用詹金斯自动化!:D Jenkins提供了环境变量,可用于补充作业中的逻辑。在本例中,您可能对
GIT_分支
和GIT_LOCAL_分支
env变量感兴趣
GIT_BRANCH - The remote branch name, if any.
GIT_LOCAL_BRANCH - The local branch name being checked out, if applicable.
因此,在您的工作中,您可以执行以下操作(bash启发的伪代码如下!!!):
也有多分支工作方法来处理不同的分支,但这是一个很好的介绍性方法来完成您试图做的事情
让我们知道它是如何运作的 要查看Jenkins注入到您工作中的其他环境变量,请查看服务器上的
env vars.html/
。例如,在localhost上,您将转到。
case ${GIT_BRANCH} in
staging) push_to_staging_sever;;
production) push_to_production_sever;;
esac