question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parameters from jobs are stripped

See original GitHub issue

Your checklist for this issue

🚨 Please review the guidelines for contributing to this repository.

  • Jenkins version

  • Plugin version

  • OS

Description

Jenkins version: 2.173 Plugin: 1.11 OS: Docker image (FROM jenkins/jenkins)

Hi,

I’m facing an issue with preconfigured jobs. I have written in yaml PipelineJob with parameters, but when I’m trying to use/pass them into job, in Jenkins they are missing. I don’t really know what’s the issue and which part of configuration is failing. Probably Job DSL plugin which I also use is worth to mention here.

Here’s a part of my yaml configuration:

    pipelineJob('Ansible-connection-test') {
      parameters {
        stringParam('HOST', 'defaultHost', 'Enter host from Ansible inventory where job should be executed')
      }
      definition {
        cps {
          script("""\
            pipeline {
              agent any
              stages {
                stage ('Checkout') {
                  steps {
                    git url: 'git@bitbucket.org:myRepo.git', branch: 'master'
                  }
                }
                stage ('Deploy') {
                  steps {
                    standardAnsibleDeploy([ansiblePlaybook:'tasks/common/listfiles/main.yml', ansibleExtras: '-e host=${HOST}'])
                  }
                }
              }
            }""".stripIndent())
        }
      }
    }

And here’s the result what’s being visible in Jenkins:

  agent any
  stages {
    stage ('Checkout') {
      steps {
        git url: 'git@bitbucket.org:szymonpronos/devops.git', branch: 'master'
      }
    }
    stage ('Deploy') {
      steps {
        standardAnsibleDeploy([ansiblePlaybook:'tasks/common/listfiles/main.yml', ansibleExtras: '-e host='])
      }
    }
  }
}

Did I made something wrong? Any workaround for that? Currently I have to manually correct all pipeline jobs. Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
jetersencommented, Apr 18, 2019

Oh, you’re talking about ${HOST}

Your issue could have been more clear. Please read the section Handling Secrets it specifically says you have to escape ${variables}

You should escape like this: ^${HOST}

JCasC is just trying to be helpful 😆

2reactions
larrycaicommented, Aug 31, 2020

even the ticket is closed, i leave one comment for escaping since someone will googled here like me.

I use helm chart to deploy the jenkins, so it has another layer to escape for this code. which I end with (\^${computer.jnlpmac})

master:
    tag: lts
    JCasC:
        configScripts:
          stage-jobs: |
            jobs:
              - script: >
                  pipelineJob('test_k8s_slave') {
                    definition {
                        cps {
                            script('''
                                podTemplate(volumes: [emptyDirVolume(mountPath: '/my-mount')], containers: [
                                        containerTemplate(name: 'jnlp', image: 'jenkins/jnlp-slave:3.35-5-alpine', args: '\^${computer.jnlpmac} \^${computer.name}'),
                                        containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: 'cat', livenessProbe: containerLivenessProbe( execArgs: 'uname -a', initialDelaySeconds: 5, timeoutSeconds: 1, failureThreshold: 3, periodSeconds: 10, successThreshold: 1))
                                ]) {

                                    node(POD_LABEL) {
                                        stage('Wait for Liveness Probe') {
                                            container('busybox') {
                                                sh 'sleep 6 && echo "Still alive"'
                                            }
                                        }
                                    }
                                }
                            '''.stripIndent())
                        }
                    }
                  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Parameters from original URL stripped after login
If the user is already logged in, all 4 parameters are retained when the user is directed to the new page. If the...
Read more >
Links with URL Parameters are stripped when sending to ...
Links with URL Parameters are stripped when sending to EmailMessage Object via API - Salesforce Developer Community.
Read more >
bkill command reference - IBM
Sends the specified signal to specified jobs. You can specify either a name, stripped of the SIG prefix (such as KILL ), or...
Read more >
Create, run, and manage Databricks Jobs
See Configure JAR job parameters. ... Whitespace is not stripped inside the curly braces, so {{ job_id }} will not be evaluated.
Read more >
Ability to add custom parameters without it being part of method
If you take traditional command line interface there are a lot flags like logging level that is nothing to do with job but...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found