Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-51521

Git parameter does not show branch list in case deleteDir() is present in pipeline

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      OS: Linux Mint 18.3 (Debian)
      Jenkins version: 2.107.2
      git-parameter-plugin version: 0.9.2
      Jenkins have only master node
    • Similar Issues:

      Description

      • At the beginning I have a code (git_url and git_cred are defined, i just hidden them):
        node {
            properties([
                parameters([
                    [
                        $class: 'GitParameterDefinition',
                        name: 'gitBranch',
                        listSize: '0',
                        type: 'PT_BRANCH',
                     ]
                 ])   
            ])
            stage("First stage") {
                git (
                    url: git_url,
                    credentialsId: git_cred
                )
            }
        }
        
      • I click "Build with parameters" on my jenkins job and get the list of branches as expected
      • After that I click "Configure" and change the code in this manner:
        node {
            properties([
                parameters([
                    [
                        $class: 'GitParameterDefinition',
                        name: 'gitBranch',
                        listSize: '0',
                        type: 'PT_BRANCH',
                     ]
                 ])   
            ])
            stage("Clean") {
                cleanWs()
                //or 'dir(env.WORKSPACE) { deleteDir() }' does not really matter
            }
            stage("First stage") {
                git (
                    url: git_url,
                    credentialsId: git_cred
                )
            }
        }
        
      • After that I click "Save" and click "Build with parameters". The list of the branches is returned correctly
      • I wait till the build is finished with the "SUCCESS" result
      • I click "Build with parameters" and get this in my parameter drop down (see "jenkins_ui_error.png" attachment
      • There is the log message (see "jenkins_error_log.txt" attachment)
      • I return the code state to the starting point ( without cleanWs() ), click "Save", click "Build with Parameters" and i see the list of branches again(notice that I didn't clicked "Build" button)

        Attachments

          Activity

          Hide
          mikita Mikita Makarenka added a comment - - edited

          Looks like I managed to walk around but it still some kind of bug from my point of view:
          The solution was to explictly specify "sortMode" in "properties" declaration

          node {
          properties([
              parameters([
                  [
                      $class: 'GitParameterDefinition',
                      name: 'gitBranch',
                      listSize: '0',
                      type: 'PT_BRANCH',
                      sortMode: 'DESCENDING'
                  ]
              ])   
          ])
          
          stage ("2") {
              cleanWs()
          }
          stage("First stage") {
              git (
                  url: git_url,
                  credentialsId: git_cred
              )
          }
          }
          
          Show
          mikita Mikita Makarenka added a comment - - edited Looks like I managed to walk around but it still some kind of bug from my point of view: The solution was to explictly specify "sortMode" in "properties" declaration node { properties([ parameters([ [ $class: 'GitParameterDefinition' , name: 'gitBranch' , listSize: '0' , type: 'PT_BRANCH' , sortMode: 'DESCENDING' ] ]) ]) stage ( "2" ) { cleanWs() } stage( "First stage" ) { git ( url: git_url, credentialsId: git_cred ) } }
          Hide
          klimas7 Boguslaw Klimas added a comment -

          Hi,

          If you useing the Snippet Generator, you should receive the complet the parameter definition, where all required field are initialization.

          properties([
              parameters([
                  [
                      $class: 'GitParameterDefinition', 
                      branch: '', 
                      branchFilter: '.*', 
                      defaultValue: '', 
                      description: '', 
                      name: 'BRANCH', 
                      quickFilterEnabled: false, 
                      selectedValue: 'NONE', 
                      sortMode: 'NONE', 
                      tagFilter: '*', 
                      type: 'PT_BRANCH'
                  ]
              ])
          ])
          

          Regardless, I will introduce the appropriate change.

          Regards
          Boguslaw

          Show
          klimas7 Boguslaw Klimas added a comment - Hi, If you useing the Snippet Generator, you should receive the complet the parameter definition, where all required field are initialization. properties([ parameters([ [ $class: 'GitParameterDefinition' , branch: '', branchFilter: '.*' , defaultValue: '', description: '', name: 'BRANCH' , quickFilterEnabled: false , selectedValue: 'NONE' , sortMode: 'NONE' , tagFilter: '*' , type: 'PT_BRANCH' ] ]) ]) Regardless, I will introduce the appropriate change. Regards Boguslaw
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: klimas7
          Path:
          src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java
          http://jenkins-ci.org/commit/git-parameter-plugin/0c75bbfca2c894c7ccabefe528090b3813f15987
          Log:
          JENKINS-51521: Default value for sortMode

          *NOTE:* This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

          Functionality will be removed from GitHub.com on January 31st, 2019.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: klimas7 Path: src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java http://jenkins-ci.org/commit/git-parameter-plugin/0c75bbfca2c894c7ccabefe528090b3813f15987 Log: JENKINS-51521 : Default value for sortMode * NOTE: * This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Boguslaw Klimas
          Path:
          src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java
          http://jenkins-ci.org/commit/git-parameter-plugin/534a2fc768b45d9b03514718824f8e48aacd0490
          Log:
          Merge pull request #65 from jenkinsci/feature/JENKINS-51521

          JENKINS-51521: Default value for sortMode

          Compare: https://github.com/jenkinsci/git-parameter-plugin/compare/2369bfe8e101...534a2fc768b4
          *NOTE:* This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

          Functionality will be removed from GitHub.com on January 31st, 2019.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Boguslaw Klimas Path: src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java http://jenkins-ci.org/commit/git-parameter-plugin/534a2fc768b45d9b03514718824f8e48aacd0490 Log: Merge pull request #65 from jenkinsci/feature/ JENKINS-51521 JENKINS-51521 : Default value for sortMode Compare: https://github.com/jenkinsci/git-parameter-plugin/compare/2369bfe8e101...534a2fc768b4 * NOTE: * This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/ Functionality will be removed from GitHub.com on January 31st, 2019.
          Hide
          klimas7 Boguslaw Klimas added a comment -

          Release version 0.9.3

          Show
          klimas7 Boguslaw Klimas added a comment - Release version 0.9.3

            People

            • Assignee:
              klimas7 Boguslaw Klimas
              Reporter:
              mikita Mikita Makarenka
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: