Jenkins steps to update helm files

327 views Asked by At

I want to edit the Helm deployment file in a step of a jenkins pipeline by using Sed.

stage('Updating Kubernetes deployment file'){
    steps {
        sh "cat deployment.yml"
        sh "sed -i 's/${APP_NAME}.*/${APP_NAME}:${IMAGE_TAG}/g' deployment.yml"
        sh "cat deployment.yml"
    }
}

And then push the changes on the repo where I have all my charts like this:

stage('Push the changed deployment file to Git'){
            steps {
                script{
                    sh """
                    git config --global user.name "vikram"
                    git config --global user.email "[email protected]"
                    git add deployment.yml
                    git commit -m 'Updated the deployment file' """
                    withCredentials([usernamePassword(credentialsId: 'github', passwordVariable: 'pass', usernameVariable: 'user')]) {
                        sh "git push http://$user:[email protected]/papealioune/gitops-demo.git dev"
                    }
                }
            }

Thank you in advance

0

There are 0 answers