Score:0

poetry command not found after installing it on jenkins

tc flag

I'm using Jenkins to build a python package using poetry, here is the stage command to install poetry on the Jenkinsfile

stage('poetry'){
  steps {
    sh 'curl -sSL https://install.python-poetry.org | python3'
    sh 'export PATH="$HOME/.local/bin:$PATH"'
    sh 'poetry --version'
  }
}

But I get this output error during the build

sh
+ curl -sSL https://install.python-poetry.org
+ python3
Retrieving Poetry metadata

The latest version (1.4.0) is already installed.
[Pipeline] sh
+ export PATH=/var/lib/jenkins/.local/bin:/var/lib/jenkins/workspace/retina3/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
+ PATH=/var/lib/jenkins/.local/bin:/var/lib/jenkins/workspace/retina3/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
[Pipeline] sh
+ poetry --version
/var/lib/jenkins/workspace/retina3@tmp/durable-deb083f7/script.sh: line 1: poetry: command not found

What could be wrong?

Score:0
jp flag

Each sh command starts its own shell session. So any variables you set in one session won't be available in another session. Instead set the variable and execute the command in the same session.

sh 'export PATH="$HOME/.local/bin:$PATH"; poetry --version'
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.