Reputation: 45
I'm using this Jenkins pipeline to create parameters from a list of directories in a Gitlab repository. New folders are constantly being uploaded to this repository, but i forced to execute this Pipeline each time that commit is executed (I want execute Jenkins pipeline manually and select an specific directory). How can I update parameters list without run pipeline job?
node {
checkout scm
def backups = sh(returnStdout: true, script: "ls $WORKSPACE")
backups.split().each {
backupArray << it
}
}
pipeline {
parameters { choice(name: 'BACKUP', choices: backupArray, description: 'Selecciona el backup para realizar el Rollback') }
agent any
stages {
stage('Realizando el Rollback con el Backup seleccionado') {
steps {
script {
sh "echo Se realiza el Rollback con el Backup $params.BACKUP"
withCredentials([string(credentialsId: 'ID', variable: 'VARIABLE')]) {
sh "script.sh $params.BACKUP"
}
}
}
}
}
post {
always {
script {
sh 'rm -rf *'
}
}
}
}
Upvotes: 2
Views: 1348
Reputation: 726
I don’t believe you can do that without executing the job at all since Jenkins needs to retrieve the latest Jenkinsfile in order to know about any updates to the parameters.
This solution could be helpful.
Basically, you set a Boolean parameter for the job and then if that is true the job will execute but all stages would be skipped. Thus the parameters of the job will get updated and the job will complete quickly.
Upvotes: 2