odavid / my-bloody-jenkins

Self Configured Jenkins Docker image based on Jenkins-LTS
MIT License
251 stars 71 forks source link

Seed job branch as variable #176

Closed jkornata closed 3 years ago

jkornata commented 3 years ago

I've successfully transitioned my Jenkins instance to My Bloody Jenkins version 2.235.5-215

The only exception is that one of the seed jobs has variable as a source branch. Unfortunately it doesn't work and with each Jenkins boot it sets the value to master (I assume it's default value).

managedConfig:
  seed_jobs:
    MyJobName:
      source:
        remote: link
        credentialsId: key
        branch: '${BRANCH_NAME}'

After each start I manually set it to desired value but each restart resets it.

Variable is defined in my pipeline file:

pipeline {
    agent {
        label 'master'
    }
    parameters {
        string(name: 'BRANCH_NAME', defaultValue: '')

Is there any way to avoid setting this value to master?

odavid commented 3 years ago

Hi, Escape it with backslash

On Mon, 16 Nov 2020 at 11:42 jkornata notifications@github.com wrote:

I've successfully transitioned my Jenkins instance to My Bloody Jenkins version 2.235.5-215

The only exception is that one of the seed jobs has variable as a source branch. Unfortunately it doesn't work and with each Jenkins boot it sets the value to master (I assume it's default value).

managedConfig: seed_jobs: MyJobName: source: remote: link credentialsId: key branch: '${BRANCH_NAME}'

After each start I manually set it to desired value but each restart resets it.

Variable is defined in my pipeline file:

pipeline { agent { label 'master' } parameters { string(name: 'BRANCH_NAME', defaultValue: '')

Is there any way to avoid setting this value to master?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/odavid/my-bloody-jenkins/issues/176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGSOAJMGED5KZ5RRSWBENDSQDXYNANCNFSM4TW52HXQ .

odavid commented 3 years ago

@jkornata

Like this:

managedConfig:
  seed_jobs:
    MyJobName:
      source:
        remote: link
        credentialsId: key
        branch: '\${BRANCH_NAME}'

see https://github.com/odavid/my-bloody-jenkins#environment-variable-substitution-and-remove-master-env-vars

jkornata commented 3 years ago

Thank you. I'm sorry, must have missed this information in the docs.