How to use the following command in Jenkins pipeline/Linux

man :

sed -i 's/foo/bar/gI' cloudformation.yml

Instead of foo, I'd like it to be the previous build number in Jenkins ${env.BUILD_ID)-1 , and bar = the current build number in jenkins = ${env.BUILD_ID}

So if currently I'm on build 133, jenkins/linux will look for the number 132 in my cloudformation file, and will replace it with 133, and so on.

Any help would be appreciated

vijay :

You can see all global variables at https://you-jenkins-url/pipeline-syntax/globals. Within a stage directive, add the below.

stage('Change-BuildID') {
   steps {
      env.previousBuildID = currentBuild.previousBuild.number
         sh "sed -i \'s/${BUILD_ID}/${env.previousBuildID}/g\' cloudformation.yml"
         }
     }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to use the following curl post command in java?

How to use Sed command to get following output?

How to use variables in Jenkins Build command

vim: how to use a match from a global command in a range following the match

How to use substitute command in unix(vi or sed) to achieve the following results

How to use the following command from R: echo "${pipestatus[1]}"?

why to use following command in sqoop?

How to debug the following Jenkins error?

How to use source command within Jenkins pipeline script

How to use xsl:if for the following?

How to use groovy env. variable in Jenkins to pass through bat command in Jenkins pipeline

How can I define/use a powershell command result in Jenkins as a Jenkins Variable?

How to use innertHTML, in this following situation

how to execute a command as root in jenkins

ZSH: how to escape the following command (variable assignment)?

How to run the following command on 3 different regions?

How to wrtie the following command in userdata cloudformation?

How to fix this Error "The following arguments are required: command"

How can I fix the following sed command?

Not able to use gsed and grep command on jenkins

Jenkins use expression/parenthesis in shell command

how do I use angular cli on a Windows Server in a Jenkins build batch command

How is a command following the while command executed over the loops?

How to use PowerPivot to Transform the following dataset into the following desired output

Jenkins: How to use jenkins pipeline Multiple parameters

What SQL command can i use to solve the following dilemma?

How to use mongodb aggregate with the following data

How to use lxml in Python to get the following elements?

How to use the R pipe operator (%>%) in the following cases