Dav*_*ams 5 jenkins jenkins-groovy jenkins-pipeline
詹金斯版本:2.176.1
我们的 Jenkinsfile 参数随着时间的推移而发生了变化,我注意到 GUI 中仍然提供旧参数,而新参数则不提供。多次运行后仍然如此。我们使用多分支管道。新的功能分支具有当前参数,但像 master 这样的旧分支则没有。
我们的 Jenkinsfile 管道是声明性的,具有管道外部的功能。我在日志中没有看到任何错误,并且看到主分支的一条日志消息,显示“ Obtained Jenkinsfile from c0c0a09ae128f788139f13b9b7fc37d473dd35bf”,这是正确的修订版。任何帮助,将不胜感激。
def checkoutCode() {
if (params.GIT_REVISION=='HEAD') {
checkout scm
} else {
checkout([$class: 'GitSCM',
branches: [[name: "${params.GIT_REVISION}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'sdfdjlkfdslfdjsdsfljds', url: 'git@github.com:company/repo.git']]
])
}
}
...
pipeline {
options {
skipDefaultCheckout()
}
agent {
label 'platform-services || platform-worker'
}
parameters {
choice(name: 'DEPLOY_ENV', choices: "staging\nproduction\n", description: '')
choice(name: 'LABEL', choices: "a\nb\nc\nd\n", description: '')
string(name: 'GIT_REVISION', defaultValue: 'HEAD', description: 'Git revision (4 or more characters) or branch name you want to check out.')
booleanParam(name: 'BUILD_ONLY', defaultValue: false, description: 'Only runs the Build and Test stages')
string(name: 'BUCKET', defaultValue: 'PARAMETER_STORE', description: 'S3 Bucket Name: PARAMETER_STORE will get value from AWS Parameter Store.')
string(name: 'CFDID', defaultValue: 'PARAMETER_STORE', description: 'Cloud Front Distribution ID: PARAMETER_STORE will get value from AWS Parameter Store.')
}
environment {
AWS_ACCOUNT_ID = getAwsParameterStoreParameter("/${params.DEPLOY_ENV}/account_id")
CLOUDFRONT_DISTRIBUTION = getJenkinsParameterValue(params.CFDID, 'CLOUDFRONT_DISTRIBUTION')
DEPLOYMENT_S3_BUCKET = getJenkinsParameterValue(params.BUCKET, 'DEPLOYMENT_S3_BUCKET')
ROLLBAR_SERVER_TOKEN = getAwsParameterStoreParameter("/${params.DEPLOY_ENV}/ROLLBAR_SERVER_TOKEN")
DEPLOY_ENV = getJenkinsParameterValue(params.DEPLOY_ENV, 'DEPLOY_ENV')
WHITE_LABEL = getJenkinsParameterValue(params.WHITE_LABEL, 'WHITE_LABEL')
NODE_CONTAINER = ''
VERSION = ''
GIT_COMMIT = ''
}
stages {
stage('Build preparations') {
steps {
script {
checkoutCode()
getAwsParameterStoreParameters()
VERSION = sh(returnStdout: true, script: 'git rev-parse HEAD').trim().take(7)
GIT_COMMIT = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
currentBuild.displayName = "#${BUILD_ID}-${params.DEPLOY_ENV}-${params.WHITE_LABEL}-${VERSION}"
NODE_CONTAINER = docker.image('node:10')
NODE_CONTAINER.inside("-e npm_config_cache=${env.WORKSPACE}/.npm -e GIT_COMMIT=${GIT_COMMIT} --env-file ${env.WORKSPACE}/env.list") {
sh 'yarn install'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2568 次 |
| 最近记录: |