pik4
pik4

Reputation: 1373

sed command in the JenkinsFile and Pipeline

I am trying to run the JenkinsFile below which contains two sed commands. But I faced different issues with string interpolation when I cat the file.

Do you know how I can run it inside the JenkinsFile? Thanks in advance.

pipeline {
    agent any
    tools {nodejs "NodeJS 6.7.0"}
    stages {
        stage('checking out gitlab branch master') {
            steps {
                checkout([$class: 'GitSCM', branches: [[name: '*/development']]])
            }
        }
        stage('executing release process') {
            environment {
                ARTIFACTORY_APIKEY = credentials('sandbox-gms-password')
            }
            steps {
                sh 'cp bowerrc.template .bowerrc'
                sh 'sed -i -e "s/username/zest-jenkins/g" .bowerrc'
                sh 'sed -i -e "s/password/${ARTIFACTORY_APIKEY}/g" .bowerrc'
                sh 'cat .bowerrc'
            }
        }
   }
}

Upvotes: 2

Views: 3643

Answers (1)

user_9090
user_9090

Reputation: 1974

Put the commands in single "sh" block, please take the reference from the below:-

pipeline {
agent any
tools {nodejs "NodeJS 6.7.0"}
stages {
    stage('checking out gitlab branch master') {
        steps {
            checkout([$class: 'GitSCM', branches: [[name: '*/development']]])
        }
    }
    stage('executing release process') {
        environment {
            ARTIFACTORY_APIKEY = credentials('sandbox-gms-password')
        }
        steps {
            sh '''
                  cp bowerrc.template .bowerrc
                  sed -i -e "s/username/zest-jenkins/g" .bowerrc
                  sed -i -e "s/password/${ARTIFACTORY_APIKEY}/g" .bowerrc
                  cat .bowerrc
               '''
        }
    }
   }
}

Upvotes: 1

Related Questions