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

          20100 Vincent Guignot created issue -
          20100 Vincent Guignot made changes -
          Field Original Value New Value
          Description Hello,

          I'll would like to use this plugin in a declarative pipeline :
          {code:java}
           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']])
          }{code}
           

          Unfortunatly the parameter entry doesn't allow to use it :
          {code:java}
            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{code}
          I found the possibilty to use it if I put it at the begining of the script in a node :
          {code:java}
          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']])
          ])
          }
           {code}
          But is this case, it override all other parameter.

           

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

          I'll would like to use this plugin in a declarative pipeline :
          {code:java}
           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']])
          }{code}
           

          Unfortunatly the parameter entry doesn't allow to use it :
          {code:java}
            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{code}
          I found the possibilty to use it if I put it at the begining of the script in a node before the pipeline :
          {code:java}
          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']])
          ])
          }
           {code}
          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 ?
          klimas7 Boguslaw Klimas made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          klimas7 Boguslaw Klimas added a comment -

          Release 0.9.4

          Show
          klimas7 Boguslaw Klimas added a comment - Release 0.9.4
          klimas7 Boguslaw Klimas made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Resolved [ 5 ]
          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:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: