Having a question which I didn't found even something that is closer to it. In a job, I have 2 string parameters :
Can I make the parameter's headline to be in red color somehow ?
thanks
tried to google it, but nothing your help is appreciated
d
You could try to do that using Active Choices ET_FORMATTED_HTML
parameter. It allows you to inject HTML (that may include JavaScript) into your "Build with parameters" page. Your JavaScript code would need to search for the "parameter's headline" (whatever you mean by that) and change its color to red.
Here's an ugly example (sorry I'm not a Javascript guy):
properties([
parameters([
[$class: 'DynamicReferenceParameter',
name: 'HTML_ADDITIONS',
choiceType: 'ET_FORMATTED_HTML',
omitValueField: true,
description: '',
script:
[$class: 'GroovyScript',
fallbackScript: [classpath: [], sandbox: false, script: ''],
script: [classpath: [], sandbox: false, script: getHtmlAdditions()]
]
],
[$class: 'StringParameterDefinition',
name: 'USERNAME',
defaultValue: '',
description: '',
trim: true,
],
[$class: 'StringParameterDefinition',
name: 'GROUP',
defaultValue: '',
description: '',
trim: true,
],
])
])
def getHtmlAdditions() {
return '''
return """
<style>
</style>
<script type="text/javascript">
jQuery(function() {
var username = jQuery("input[type=hidden][value=USERNAME]").parents(".tr")
username.css('background-color', 'red')
})
</script>
"""
'''
}
pipeline {
agent any
stages {
stage('hello') {
steps {
script {
sh "echo hello"
}
}
}
}
}
A couple of script approvals later, and you get this:
While at it, you could similarly find the HTML_ADDITIONS
field and invoke hide()
on it, so that only USERNAME
and GROUP
are presented to the user:
jQuery("input[type=hidden][value=HTML_ADDITIONS]").parents(".tr").hide()