Getting the following error when trying to bring my credentials into Jenkinsfile:
Wondering what the fix for this is?
WorkflowScript: 8: Environment variable values must either be single quoted, double quoted, or function calls. @ line 8, column 23.
DOCKER_USERNAME = credentials(‘Jenkey’).username
^
WorkflowScript: 9: Environment variable values must either be single quoted, double quoted, or function calls. @ line 9, column 23.
DOCKER_PASSWORD = credentials(‘Jenkey’).password
pipeline {
agent any
environment {
DOCKER_REGISTRY = “docker.io”
DOCKER_IMAGE = “10088989/my-node-app”
DOCKER_TAG = “latest”
DOCKER_USERNAME = credentials(‘Jenkey’).username
DOCKER_PASSWORD = credentials(‘Jenkey’).password
}
stages {
stage(‘Build’) {
steps {
withCredentials([usernamePassword(credentialsId: ‘Jenkey’, usernameVariable: ‘DOCKER_USERNAME’, passwordVariable: ‘DOCKER_PASSWORD’)]) {
sh “docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY”
sh “docker build -t $DOCKER_REGISTRY/$DOCKER_IMAGE:$DOCKER_TAG .”
^