5

Jenkins version: 2.176.1

Our Jenkinsfile's parameters have changed over time and I've noticed that old parameters are still offered in the GUI and a new one isn't. This is still the case after multiple runs. We use a multi branch pipeline. New feature branches have the current parameters, but old branches like master do not.

Our Jenkinsfile pipeline is declarative with functions outside of the pipeline. I don't see any errors in the logs and I see a log message for the master branch that says Obtained Jenkinsfile from c0c0a09ae128f788139f13b9b7fc37d473dd35bf which is the correct revision. Any help would be appreciated.

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'
        }
      }
    }
  }
David Williams
  • 401
  • 3
  • 15
  • You can check whether the code is getting successfully checked out at your given location – user_9090 Jun 17 '19 at 11:02
  • We also started seeing this after upgrading to Jenkins 2.176.1. We're dealing with a GitHub-org-generated multibranch pipeline with parameters defined in a Jenkinsfile. The job's "view configuration" page shows the correct/up-to-date parameters, but actual behavior is as you've described. I don't have a solution, but this seemed to resolve by itself after about a day. – Jonathan Jun 28 '19 at 18:12
  • 1
    This is still an issue for me. I've noticed that new branches have the correct parameters. – David Williams Aug 30 '19 at 13:43
  • This looks suspiciously like an open Jenkins issue: https://issues.jenkins-ci.org/browse/JENKINS-60459 – dolphy May 12 '20 at 14:17

0 Answers0