Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 1.63 KB

CredentialsPlugin.md

File metadata and controls

36 lines (28 loc) · 1.63 KB

Enable this plugin to inject credentials into your stages using the Jenkins Credentials Plugin.

One-time setup:

Add any number of credentials bindings that you want to wrap your stages, with withBinding. Each call to this method will cumulatively add more credentials. See the Credentials Binding Plugin homepage for the list of supported bindings.

// Jenkinsfile
@Library(['terraform-pipeline@v5.0']) _

Jenkinsfile.init(this)

// Add credentials to all Stages from usernamePassword, usernameColonPassword, and string credentials
CredentialsPlugin.withBinding { usernamePassword(credentialsId: 'my-user-pass', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD') }
                 .withBinding { usernameColonPassword(credentialsId: 'my-user-colon-pass', variable: 'USERPASS') }
		 .withBinding { string(credentialsId: 'my-string-token', variable: 'TOKEN') }
		 .init()

def validate = new TerraformValidateStage()
def build = new BuildStage()
def deployQa = new TerraformEnvironmentStage('qa')
def testQa = new RegressionStage()
def deployUat = new TerraformEnvironmentStage('uat')
def deployProd = new TerraformEnvironmentStage('prod')

validate.then(build)
        .then(deployQa)
        .then(testQa)
        .then(deployUat)
        .then(deployProd)
        .build()