There is a script file in the root directory of the jenkins project, as shown in the figure
There is a simple output in the file
We want to execute this script file in the jenkins pipeline, how to configure the jenkins pipe command
First of all, to be clear, we are in the jenkins pipeline, the default is the root directory of the corresponding project folder in the Jenkins workspace folder, for example, the pipe project we are currently testing is named Pipeline in jenkins, then Our current path is under the file path as shown in the figure below
Therefore, we can get the script file (./) through ./liubo.sh to refer to the current path
Therefore, if we want to execute the liubo.sh script file, we can pass the command
pipeline {
agent any
environment {
liubosh = "./liubo.sh"
}
stages {
stage('checkout') {
steps {
git branch: "master", url: "https://gitee.com/liuboliu/pengpailiubo.git"
}
}
stage('build') {
steps {
sh """
chmod -R +x ${liubosh}
${liubosh}
"""
}
}
}
}
Execution, as shown in the figure below, successfully executes the script