Chúng ta khám phá các parameters trong Jenkins thông qua ví dụ bên dưới.
pipeline{
agent{
label 'jenkins-k8s-agent'
}
parameters{
string(name: 'environment', defaultValue: 'Dev', description: 'Environment to build for(Valid values: "Dev, Text, Prod")')
string(name: 'version', defaultValue: '1.0', description: 'Version number to build for')
booleanParam(name: 'to_deploy_to_environment', defaultValue: true, description: '')
choice(choices: 'Ha-Noi\nHo-Chi-Minh', description: 'Version number to build for', name: 'region')
text(name: 'myText', defaultValue: 'myTextValue', description: 'myTextDesciption')
password(name: 'myPassword', defaultValue: 'myPasswordValue', description: 'myPasswordDesciption')
file(name: 'myFile', description: 'myFileDesciption')
credentials(name: 'myCredentials', defaultValue: 'myCredentialsValue', required: true)
}
stages{
stage('Example'){
steps{
echo "We are build for ${params.environment}, ${params.version}, and we are deploying to environment: ${params.to_deploy_to_environment}"
echo "region: ${params.region}, myText: ${params.myText}, myPassword: ${params.myPassword}, and myfile: ${params.myFile}"
echo "selected credentials is: ${params.myCredentials}"
}
}
}
}
Sau đó anh em nhấn build:
Vậy bài hết òi. Mình gõ tay đống đó mệt vl