def call(String approval_flag) {
if(approval_flag == "Yes"){
userInput = input(id: 'confirm', message: "Should we continue?", ok: "Yes, we should.", submitter: "devops")
}else{
sleep 10
}
}
@Library('pipeline-library-demo') _
import com.cleverbuilder.GlobalVars
import com.cleverbuilder.SampleClass
pipeline {
agent any
parameters {
choice(name: "NODE_LABEL", choices: ["YOUR_PROJECT-jenkins-1"])
string(name: 'PROJECT_NAME', defaultValue: 'YOUR_PROJECT-wordpress', description: 'Enter service name?')
choice(name: 'ENVIRONMENT', choices: ['dev'], description: 'Enter short environment name?')
choice(name: 'GET_APPROVAL', choices: ['No', 'Yes'], description: 'Do you want to confirm before going to the next or not?')
}
stages {
stage('Demo') {
steps {
echo 'Hello, world'
sayHello 'Dave'
echo "Sum 8888 and 9999 : ${sum(8888,9999)}"
echo 'The value of foo is : ' + GlobalVars.foo
get_approval_from_user("${params.GET_APPROVAL}")
script {
def person = new SampleClass()
person.age = 21
person.increaseAge(10)
echo 'Incremented age, is now : ' + person.age
}
}
}
}
}
Step 1: Create a private channel
Step 2: Add the bot(@alert_prd_bot) to the channel
Step 3: Use the API below to get the ID of the channel. It has format like tat -100xxx
step 4: check id by
curl -i https://api.telegram.org/bot${YOUR_TOKEN}/getUpdates
https://www.tutorialworks.com/jenkins-shared-library/
https://www.eficode.com/blog/jenkins-groovy-tutorial