3
我想将一些工作转换为新的Jenkins 2.0声明式管道。目前他们是3个不同的工作:声明式Jenkins管道与每晚部署主分支
- CI-> PollSCM每5分钟(只有主人),建立和运行测试。
- 勉强 - >每晚运行(在夜间服务器上进行构建,测试,集成测试和部署)
- Sprintly - >这是一个参数化作业,每周四使用手动创建标签运行。 (构建,测试,集成测试和部署sprintly服务器上)
为此,我在春天与Maven一个小项目,这将是对我来说,开始最好的例子(简单,方便,快捷是建)。
目前我已经有一个CI构建的Multibranch管道,但是我想在Nightly和Sprintly构建中集成到这个工作中。
- 夜间:夜间在主分支上运行一个Cron作业,在Nightly Server中部署为 。
- Sprintly:通过Sprintly_tag生成,由我在主分支中生成,并部署到Sprintly Server中。
目前,我有这个JenkinsFile
pipeline {
agent {
label 'master'
}
tools {
maven "Apache Maven 3.3.9"
jdk "Java JDK 1.8 U102"
}
triggers {
cron ('H(06-08) 01 * * *')
pollSCM('H/5 * * * *')
}
stages {
stage('Build') {
steps {
sh 'mvn -f de.foo.project.client/ clean package'
}
post {
always {
junit allowEmptyResults: true, testResults: '**/target/surefire-reports/*.xml'
archiveArtifacts allowEmptyArchive: true, artifacts: '**/target/*.war'
}
}
}
stage('Deploy') {
sh 'echo "Deploy only master"'
}
}
它运行每个分支当东西拉Git和也跑在晚上大约1点钟(但仍在运行的所有分支机构)。
任何想法或暗示要做到这一点?不需要执行部署的代码我只想知道如何过滤/拆分处于同一JenkinsFile中的分支
非常感谢大家!
编辑: 我也可以使用,但它会在夜间运行,所有的树枝(我只能为cron作业使这个过滤器?)
stage('DeployBranch') {
when { branch 'story/RTS-525-task/RTS-962'}
steps {
sh 'echo "helloDeploy in the branch"'
}
}
stage('DeployMaster') {
when { branch 'master'}
steps {
sh 'echo "helloDeploy in the master"'
}
}