I have a puzzle for you!
I am trying to create a choice parameter from in jenkins to prompt for items to download from sharepoint.Hoever, I can seem to get the id value from a list that contains multiple items....
code
def teamList = [
[name: 'Select', id: null],
[name: 'team1', id: 'teamcred1'],
[name: 'team2', id: 'teamcred2'],
]
...
stage('Get: info') {
getStuff(teamList)
}
...
def getStuff(teamList) {
script {
def infoIn = input(
id: 'in', message: 'What file?', ok: 'Select',
parameters: [
string(defaultValue: '',
description: 'File name',
name: 'file'),
string(defaultValue: '',
description: 'Path ?',
name: 'path'),
[$class: 'ChoiceParameterDefinition',
name: 'team',
choices: teamList.name as List,
description: 'Teams '],
])
selectedTeam = teamList.find{it.name == infoIn.name}.id
# def inputTeam = infoIn.name?:''
def inputPath = infoIn.path?:'Documents'
def inputFile = infoIn.file?:''
echo "Team: ${inputTeam}"
echo "file: ${inputFile}"
echo "Path: ${inputPath}"
echo "Team: ${inputTeam}"
...
and the error:
java.lang.NullPointerException: Cannot get property 'id' on null object
Why can't I get the id value from the team list when I have more than one input entry? the prompt for information seen in the pipeline works fine, and we have the dropdown with the team list names.... But, when I try to get the id, it fails and if I ask for only the team and forget about the file and path in the input block, it works fine? why is that?
Ta,
X