mschuchard / jenkins-devops-libs

Collection of Jenkins Pipeline shared libraries for common DevOps software.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unexpected token: && @ line 150, column 31.

moleksyuk opened this issue · comments

Hi,

I'm trying to call init method of v1.4.0.

@Library('jenkins-devops-libs') _

import java.time.LocalDateTime

node('deployment') {
    def ROOT_DEPLOYMENT_DIR = ''

    // skipped properties definition

    stage('Checkout') {
        checkout scm
    }

    stage('Prepare Environment') {
        def awsRegion = params.AWS_AZ[0..-1]
        ROOT_DEPLOYMENT_DIR = "srv/${params.ENVIRONMENT}/${awsRegion}/${params.AWS_AZ}"
    }

    stage('mystage') {
        dir("${ROOT_DEPLOYMENT_DIR}/myfolder") {
            sh "pwd"
            terraform.init(dir: "${ROOT_DEPLOYMENT_DIR}/myfolder")
        }
    }
}

but getting such error:

org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup failed:
/var/jenkins_home/jobs/Misha/builds/13/libs/jenkins-devops-libs/vars/terraform.groovy: 150: unexpected token: && @ line 150, column 31.
       if (config.check == true) && (fmt_status != 0) {

UPDATE:
Oh, seems like syntax error in script - missing additional braces:

if (config.check == true) && (fmt_status != 0) {

but should be as:

if ((config.check == true) && (fmt_status != 0)) {

Hi, sorry but Github stopped giving me notifications for the first few months of the year, so I have only just seen this. I have verified that the change to the line you listed above was made after the last round of acceptance testing. It does appear to be a syntax error.

It has been fixed in 771254f. it will be reflected in the upcoming patch release 1.4.1.