【发布时间】:2019-01-28 09:46:57
【问题描述】:
我们在 GitHub 上有一个项目,其中有两个 Jenkins Multibranch Pipeline 作业 - 一个构建项目,另一个运行 测试。这两个管道之间的唯一区别是它们具有不同的 JenkinsFiles。
我有两个我怀疑彼此相关的问题:
- 在 GitHub 状态检查部分,我只看到一个标题如下的检查:
continuous-integration/jenkins/pr-merge — This commit looks good, 这将我引导到 test Jenkins 管道。这意味着我们的 build 管道没有被 GitHub 获取,即使它在 Jenkins 上可见。我怀疑这是因为这两个检查具有相同的名称(即continuous-integration/jenkins/pr-merge)。 - 我无法弄清楚如何为每个 Jenkins 作业(即 test 和 build)重命名状态检查消息。我遇到过this 类似的问题,但它的解决方案不适用于我们,因为 Build Triggers 在 Multibranch Pipelines 中不可用
如果有人知道如何为 Jenkins 多分支流水线按作业更改此消息,那将非常有帮助。谢谢!
编辑(只是更多信息):
我们已经在存储库上设置了 GitHub/Jenkins webhook,并且我们的 build 和 test 作业都开始构建,只是状态检查/消息没有' 两者都不会显示在 GitHub 上(似乎仅适用于 test)。 这是 build 作业的 JenkinsFile:
#!/usr/bin/env groovy
properties([[$class: 'BuildConfigProjectProperty', name: '', namespace: '', resourceVersion: '', uid: ''], buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')), [$class: 'ScannerJobProperty', doNotScan: false]])
node {
stage('Initialize') {
echo 'Initializing...'
def node = tool name: 'node-lts', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
env.PATH = "${node}/bin:${env.PATH}"
}
stage('Checkout') {
echo 'Getting out source code...'
checkout scm
}
stage('Install Dependencies') {
echo 'Retrieving tooling versions...'
sh 'node --version'
sh 'npm --version'
sh 'yarn --version'
echo 'Installing node dependencies...'
sh 'yarn install'
}
stage('Build') {
echo 'Running build...'
sh 'npm run build'
}
stage('Build Image and Deploy') {
echo 'Building and deploying image across pods...'
echo "This is the build number: ${env.BUILD_NUMBER}"
// sh './build-openshift.sh'
}
stage('Upload to s3') {
if(env.BRANCH_NAME == "master"){
withAWS(region:'eu-west-1',credentials:'****') {
def identity=awsIdentity();
s3Upload(bucket:"****", workingDir:'build', includePathPattern:'**/*');
cfInvalidate(distribution:'EBAX8TMG6XHCK', paths:['/*']);
}
};
if(env.BRANCH_NAME == "PRODUCTION"){
withAWS(region:'eu-west-1',credentials:'****') {
def identity=awsIdentity();
s3Upload(bucket:"****", workingDir:'build', includePathPattern:'**/*');
cfInvalidate(distribution:'E6JRLLPORMHNH', paths:['/*']);
}
};
}
}
【问题讨论】:
-
你检查this的答案了吗?
-
我看过它,但它似乎不适合我们的 JenkinsFile 结构。我们正在运行一个节点项目,所以我不知道文件是否会有所不同。我会将我们的 JenkinsFile 的副本添加到问题中,以便您查看它 - 我对 JenkinsFiles 的经验很少,因此我们将不胜感激。
-
已回复。