Vue normale

Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.
À partir d’avant-hierChlouchloutte ¯\_(ツ)_/¯

Note: jenkins - Add a parameters live from a shared lib

3 août 2020 à 13:16

In a Groovy class:


private final Script script;

public MyClass(Script script) {
    this.script = script;
}

public myMethod() {
    this.script.env.test = "prout"
    this.script.println(this.script.env.test)

    this.script.properties([
       this.script.parameters([
            this.script.string(defaultValue: "${MY_VALUE}", description: 'the value', name: "${the_name}", trim: true),
            this.script.password(defaultValue: "${MY_PASSWORD}", description: 'the password', name: "${the_password}", trim: true)
        ])
    ])
}

In the pipeline:

stage('My Stage') {
    steps {
        script {
            MyClass toto = MyClass(this);
           toto.myMethod();
        }
    }
}

Permalien

❌
❌