How to use pom version in shell command in jenkinsfile?


username

I'm trying to get the pom.xml version in a Jenkinsfile and then use that version in a shell script. An exception occurs bad substitutionwhen trying to use it pom.version. What is the correct syntax to pass the pom version?

script {
    def pom = readMavenPom file: 'pom.xml'

    withCredentials(...) {

        sh '''#!/bin/bash                                        
              cp "${WORKSPACE}/target/stats-${pom.version}-shaded.jar" /xyz
        '''
    }                   
}

I installed the plugin Pipeline Utility Stepsfor readMavenPomcmd without restarting Jenkins. Do I need to restart Jenkins?

Simon Stefanik

If you want to replace ${pom.version}, you need to use GString. The triple quotes you are using define a multi-line Java string that does not support variable substitution. You need to replace two variables , and '''define """one more GString that can be replaced .${WORKSPACE}${pom.version}

Related


How to use pom version in shell command in jenkinsfile?

username I'm trying to get the pom.xml version in a Jenkinsfile and then use that version in a shell script. An exception occurs bad substitutionwhen trying to use it pom.version. What is the correct syntax to pass the pom version? script { def pom = readM

How to use pom version in shell command in jenkinsfile?

username I'm trying to get the pom.xml version in a Jenkinsfile and then use that version in a shell script. An exception occurs bad substitutionwhen trying to use it pom.version. What is the correct syntax to pass the pom version? script { def pom = readM

How to use pom version in shell command in jenkinsfile?

username I'm trying to get the pom.xml version in a Jenkinsfile and then use that version in a shell script. An exception occurs bad substitutionwhen trying to use it pom.version. What is the correct syntax to pass the pom version? script { def pom = readM

How to use pom version in shell command in jenkinsfile?

username I'm trying to get the pom.xml version in a Jenkinsfile and then use that version in a shell script. An exception occurs bad substitutionwhen trying to use it pom.version. What is the correct syntax to pass the pom version? script { def pom = readM

How to use pom version in shell command in jenkinsfile?

username I'm trying to get the pom.xml version in a Jenkinsfile and then use that version in a shell script. An exception occurs bad substitutionwhen trying to use it pom.version. What is the correct syntax to pass the pom version? script { def pom = readM

How to use pom version in shell command in jenkinsfile?

username I'm trying to get the pom.xml version in a Jenkinsfile and then use that version in a shell script. An exception occurs bad substitutionwhen trying to use it pom.version. What is the correct syntax to pass the pom version? script { def pom = readM

Jenkinsfile and POM version

Matthew After we get the POM model, as described in Krzysztof Krasoń 's answer to extract the pom version in the jenkins pipeline . Calling pom.version returns the fully qualified name of the artifact, not just the version. E.g @NonCPS def version() { pom

How to pass variables from Jenkinsfile to shell command

Joe: I would like to use a variable inside a Jenkinsfilescript and then pass its value to shell script execution (either as an environment variable or command line argument). But the following Jenkinsfile: for (i in [ 'a', 'b', 'c' ]) { echo i sh 'echo

How to pass variables from Jenkinsfile to shell command

Joe: I would like to use a variable inside a Jenkinsfilescript and then pass its value to shell script execution (either as an environment variable or command line argument). But the following Jenkinsfile: for (i in [ 'a', 'b', 'c' ]) { echo i sh 'echo

How to use jenkins version number plugin in Jenkinsfile?

Dmitry Buzolin Try this step in your Jenkinsfile with "Version Number Plugin" installed: stage("Build") { echo "Building..." TAG = ${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY} sh "docker build -t $IMAGE:$TAG ." }

How to use jenkins version number plugin in Jenkinsfile?

Dmitry Buzolin Try this step in your Jenkinsfile with "Version Number Plugin" installed: stage("Build") { echo "Building..." TAG = ${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY} sh "docker build -t $IMAGE:$TAG ." }

How to use jenkins version number plugin in Jenkinsfile?

Dmitry Buzolin Try this step in your Jenkinsfile with "Version Number Plugin" installed: stage("Build") { echo "Building..." TAG = ${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY} sh "docker build -t $IMAGE:$TAG ." }

How to use jenkins version number plugin in Jenkinsfile?

Dmitry Buzolin Try this step in your Jenkinsfile with "Version Number Plugin" installed: stage("Build") { echo "Building..." TAG = ${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY} sh "docker build -t $IMAGE:$TAG ." }

Execute shell command from jenkinsfile

Hardik Lasode I am trying to execute a set of commands from a jenkinsfile. The problem is when I try to assign the value of stdout to a variable it doesn't work. I've tried different combinations of double and single quotes, but no luck so far. Here I executed

Execute shell command from jenkinsfile

Hardik Lasode I am trying to execute a set of commands from a jenkinsfile. The problem is when I try to assign the value of stdout to a variable it doesn't work. I've tried different combinations of double and single quotes, but no luck so far. Here I executed

How to use at command in shell script?

User 2177896: I'm trying to use a Unix command atin a shell script (to set a job to run at a specific time). The time will be specified by user input using getopts and optarg, they seem to work fine, the problem is at. How can I write a command to a script to

How to use at command in shell script?

User 2177896: I'm trying to use a Unix command atin a shell script (to set a job to run at a specific time). The time will be specified by user input using getopts and optarg, they seem to work fine, the problem is at. How can I write a command to a script to

How to use at command in shell script?

User 2177896: I'm trying to use a Unix command atin a shell script (to set a job to run at a specific time). The time will be specified by user input using getopts and optarg, they seem to work fine, the problem is at. How can I write a command to a script to

Jenkins pipeline with parameters in shell command in Jenkinsfile

Martin I am trying to use defined parameters Jenkinsfilein several shell commands , but I am getting an exception. In my example I want to execute a simple docker command. This parameter defines the path to the docker executable. Here is my very short Jenkinsf

Jenkins pipeline with parameters in shell command in Jenkinsfile

Martin I am trying to use defined parameters Jenkinsfilein several shell commands , but I am getting an exception. In my example I want to execute a simple docker command. This parameter defines the path to the docker executable. Here is my very short Jenkinsf

Jenkins pipeline with parameters in shell command in Jenkinsfile

Martin I am trying to use defined parameters Jenkinsfilein several shell commands , but I am getting an exception. In my example I want to execute a simple docker command. This parameter defines the path to the docker executable. Here is my very short Jenkinsf

Jenkins pipeline with parameters in shell command in Jenkinsfile

Martin I am trying to use defined parameters Jenkinsfilein several shell commands , but I am getting an exception. In my example I want to execute a simple docker command. This parameter defines the path to the docker executable. Here is my very short Jenkinsf

Jenkins pipeline with parameters in shell command in Jenkinsfile

Martin I am trying to use defined parameters Jenkinsfilein several shell commands , but I am getting an exception. In my example I want to execute a simple docker command. This parameter defines the path to the docker executable. Here is my very short Jenkinsf

Jenkins pipeline with parameters in shell command in Jenkinsfile

Martin I am trying to use defined parameters Jenkinsfilein several shell commands , but I am getting an exception. In my example I want to execute a simple docker command. This parameter defines the path to the docker executable. Here is my very short Jenkinsf

How to vary shell script output on Maven pom.xml to use

Peter I'm wondering if there is a way to make maven execute a shell script of curl resources and make the response available, such as environment variables or global variables that maven can reference, or is it possible to do this Groovy? So when I do a maven

How to vary shell script output on Maven pom.xml to use

Peter I was wondering if there is a way to make maven execute a shell script of curl resources and make the response available, such as an environment variable or global variable that maven can reference, or is it possible to do this Groovy? So when I do a mav

How to vary shell script output on Maven pom.xml to use

Peter I'm wondering if there is a way to make maven execute a shell script of curl resources and make the response available, such as environment variables or global variables that maven can reference, or is it possible to do this Groovy? So when I do a maven

How to vary shell script output on Maven pom.xml to use

Peter I was wondering if there is a way to make maven execute a shell script of curl resources and make the response available, such as an environment variable or global variable that maven can reference, or is it possible to do this Groovy? So when I do a mav

How to vary shell script output on Maven pom.xml to use

Peter I was wondering if there is a way to make maven execute a shell script of curl resources and make the response available, such as an environment variable or global variable that maven can reference, or is it possible to do this Groovy? So when I do a mav