Jenkins在多次运行后未更新管道参数

时间:2019-06-14 16:56:30

标签: jenkins jenkins-pipeline jenkins-groovy

Jenkins版本:2.17.61

我们的Jenkinsfile的参数已随着时间而改变,我注意到GUI中仍然提供了旧参数,而没有提供新参数。多次运行后仍然如此。我们使用多分支管道。新功能分支具有当前参数,而旧分支(例如master)则没有。

我们的Jenkinsfile管道是声明性的,其功能在管道之外。我在日志中没有看到任何错误,并且看到了master分支的日志消息,该消息显示从c0c0a09ae128f788139f13b9b7fc37d473dd35bf 获得的Jenkinsfile 。任何帮助将不胜感激。

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'
        }
      }
    }
  }

0 个答案:

没有答案