[JIRA] (JENKINS-45685) Declarative Pipeline Example

6 views
Skip to first unread message

sean.middleton@dxc.com (JIRA)

unread,
Sep 13, 2018, 3:52:02 AM9/13/18
to jenkinsc...@googlegroups.com
Sean Middleton commented on Task JENKINS-45685
 
Re: Declarative Pipeline Example

Hi, was there any update on this issue in the end? Looking to use the Vault plugin with a declarative pipeline but some information I've read suggests declarative pipelines aren't currently supported with the Vault plugin? 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

arturas.radzevicius@devbridge.com (JIRA)

unread,
Oct 11, 2018, 8:17:01 AM10/11/18
to jenkinsc...@googlegroups.com
Arturas R commented on Task JENKINS-45685
 
Re: Declarative Pipeline Example

Hope it helps

pipeline {
  agent none
  stages {
    stage('Vault') {
        agent {
          node {
            label 'linux'
          }
        }

        steps {
          script {
            node {
              // define the secrets and the env variables
              def secrets = [
                [$class: 'VaultSecret', path: 'secret/testing', secretValues: [
                  [$class: 'VaultSecretValue', envVar: 'testing', vaultKey: 'value_one'],
                  [$class: 'VaultSecretValue', envVar: 'testing_again', vaultKey: 'value_two']]],
                [$class: 'VaultSecret', path: 'secret/another_test', secretValues: [
                  [$class: 'VaultSecretValue', envVar: 'another_test', vaultKey: 'value']]]
              ]

              // optional configuration, if you do not provide this the next higher configuration
              // (e.g. folder or global) will be used
              def configuration = [$class: 'VaultConfiguration',
                                  vaultUrl: 'http://my-very-other-vault-url.com',
                                  vaultCredentialId: 'my-vault-cred-id']

              // inside this block your credentials will be available as env variables
              wrap([$class: 'VaultBuildWrapper', configuration: configuration, vaultSecrets: secrets]) {
                sh 'echo $testing'
                sh 'echo $testing_again'
                sh 'echo $another_test'
              }
            }
          }
        }
      }
    }
  }
}

vmarjunits@gmail.com (JIRA)

unread,
Oct 18, 2019, 6:12:02 AM10/18/19
to jenkinsc...@googlegroups.com
vassil marjunits commented on Task JENKINS-45685
 
Re: Declarative Pipeline Example

After version 2.3.0 and higher,
3.0.0 was latest, when this comment was made

// define vault configuration
def configuration = [engineVersion: 1, skipSslVerification: true, timeout: 60, vaultUrl: 'http://172.21.0.2:8200', vaultCredentialId: "my-vault-cred-id"]
// define vault secret path and env var
def secret = [
      [path: 'dev/kv1', secretValues: [
        [envVar: 'PASSWORD', vaultKey: 'password'],
        [envVar: 'USER', vaultKey: 'user']]]
]pipeline {
    agent any
    options {
        buildDiscarder(logRotator(numToKeepStr: '20'))
        disableConcurrentBuilds()
    }
    stages{   
        stage('Vault') {
            steps {
                script {
                    withVault([configuration: configuration, vaultSecrets: secret]) {
                         sh 'echo $PASSWORD'
                         sh 'echo $USER'
                    }
                }
            }  
        }
    }
    post {
        always {
            cleanWs()
        }
    }
}


 

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

vmarjunits@gmail.com (JIRA)

unread,
Oct 18, 2019, 6:16:05 AM10/18/19
to jenkinsc...@googlegroups.com
After version 2.3.0 and higher,
3.0.0 was latest, when this comment was made
{code:java}

// define vault configuration
def configuration = [engineVersion: 1,

skipSslVerification: true,
timeout: 60,
vaultUrl: ' " http:// 172 my-vault . 21.0.2 com :8200 ' " ,
vaultCredentialId: "my-vault-cred-id"]
// define vault secret path and env var
def secret = [
      [path: 'dev/kv1', secretValues: [
        [envVar: 'PASSWORD', vaultKey: 'password'],
        [envVar: 'USER', vaultKey: 'user']]]
]pipeline {
    agent any
    options {
        buildDiscarder(logRotator(numToKeepStr: '20'))
        disableConcurrentBuilds()
    }
    stages{   
        stage('Vault') {
            steps {
                script {
                    withVault([configuration: configuration, vaultSecrets: secret]) {
                     sh 'echo $PASSWORD'
                     sh 'echo $USER'
                    }
                }
            }  
        }
    }
    post {
        always {
            cleanWs()
        }
    }
}


{code}




 

vmarjunits@gmail.com (JIRA)

unread,
Oct 18, 2019, 6:17:02 AM10/18/19
to jenkinsc...@googlegroups.com
vassil marjunits edited a comment on Task JENKINS-45685
After version 2.3.0 and higher,
3.0.0 was latest, when this comment was made
{code:java}
// define vault configuration
def configuration = [engineVersion: 1,
                     skipSslVerification: true,
                     timeout: 60,
                     vaultUrl: "http://my-vault.com:8200",
Reply all
Reply to author
Forward
0 new messages