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

Support git-parameter-plugin in declarative pipeline

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Hello,

      I'll would like to use this plugin in a declarative pipeline :

       pipeline { 
          agent {
      	    dockerfile {(...)
      		}
      	}
      	options {
      		timestamps()
      		//Jobs properties
      		buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10'))
      		disableConcurrentBuilds()
      	}	parameters {
      		string(defaultValue: '', description: 'Refs to build', name: 'ref')
          	booleanParam(defaultValue: false, description: 'Release mode', name: 'release')
          	string(defaultValue: '', description: 'Qualifier to use in release mode only.', name: 'qualifier', trim: true)
          	parameters([[$class: 'GitParameterDefinition', branch: '', branchFilter: '.*', defaultValue: '', description: 'Tag to choosen', listSize: '0', name: 'tag', quickFilterEnabled: false, selectedValue: 'NONE', sortMode: 'NONE', tagFilter: '*', type: 'PT_TAG']])
      	}

       

      Unfortunatly the parameter entry doesn't allow to use it :

        Valid parameter types: [booleanParam, choice, credentials, file, text, password, run, string] @ line 42, column 7.
             	 parameters([[$class: 'GitParameterDefinition', branch: '', branchFilter: '.*', defaultValue: '', description: 'Tag to choosen', listSize: '0', name: 'tag', quickFilterEnabled: false, selectedValue: 'NONE', sortMode: 'NONE', tagFilter: '*', type: 'PT_TAG']])
               ^1 error

      I found the possibilty to use it if I put it at the begining of the script in a node before the pipeline :

      node {
      	properties([
          parameters([[$class: 'GitParameterDefinition', branch: '', branchFilter: '.*', defaultValue: '', description: 'Tag to choosen', listSize: '0', name: 'tag', quickFilterEnabled: false, selectedValue: 'NONE', sortMode: 'NONE', tagFilter: '*', type: 'PT_TAG']])
      ])
      }
       

      But is this case, it override all others parameters.

       

      So is it possible to add the support of git-parameter-plugin directly inside the parameters closure  like string, boolean, etc ?

        Attachments

          Activity

          Hide
          klimas7 Boguslaw Klimas added a comment -

          Release 0.9.4

          Show
          klimas7 Boguslaw Klimas added a comment - Release 0.9.4
          Hide
          klimas7 Boguslaw Klimas added a comment -

          Example script

          Important settings:

          • It should be set a default value because initial build must get this information
          • Using git should be set a branchFilter as 'origin/(.*)' (origin is a remote server name)

           

          pipeline {
              agent any
              parameters {
                  gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH'
              }
              stages {
                  stage('Example') {
                      steps {
                          git branch: "${params.BRANCH}", url: 'https://github.com/jenkinsci/git-parameter-plugin.git'
                      }
                  }
              }
          }
          
          Show
          klimas7 Boguslaw Klimas added a comment - Example script Important settings: It should be set a default value because initial build must get this information Using git  should be set a branchFilter as 'origin/(.*)' (origin is a remote server name)   pipeline { agent any parameters { gitParameter branchFilter: 'origin/(.*)' , defaultValue: 'master' , name: 'BRANCH' , type: 'PT_BRANCH' } stages { stage( 'Example' ) { steps { git branch: "${params.BRANCH}" , url: 'https: //github.com/jenkinsci/git-parameter-plugin.git' } } } }
          Hide
          apgray Andrew Gray added a comment -

          Does this support getting the list of tags on a branch?  If so, what's the syntax?

           

          The below doesn't work;

          parameters {
                  gitParameter tagFilter: 'origin/master', name: 'TAG', type: 'PT_TAG'   
          }
          

           

           

          Show
          apgray Andrew Gray added a comment - Does this support getting the list of tags on a branch?  If so, what's the syntax?   The below doesn't work; parameters {         gitParameter tagFilter: 'origin/master' , name: 'TAG' , type: 'PT_TAG'     }    

            People

            • Assignee:
              klimas7 Boguslaw Klimas
              Reporter:
              20100 Vincent Guignot
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: