I work on a SpringBoot + Angular project. It is a very old project and it has not been built on Jenkins for month (I am new to the company) I don't have admin credentials on Jenkins, I can only create Pipelines that use docker images, provided by devops team, as agent.
I am trying to build my spring boot app with maven+jdk image agent and then building the angular project (npm install) with the node image agent. I have defined no default agent for my pipeline (agent none)
pipeline {
agent none // Pas d'agent par défaut
stages {
stage('CleanWorkspace') {
steps {
script {
cleanWs()
}
}
}
stage('Checkout scm') {
steps {
// checking out git branch
sh 'git checkout $BRANCH_SCOPE'
}
}
stage('Read POM Version') {
steps {
script {
def pomFile = readFile('./prism-ui/pom.xml')
def pomXml = new XmlSlurper().parseText(pomFile)
env.BUILDVERSION = pomXml.version.text()
def currentBranch = env.BRANCH_SCOPE
echo "The version in the POM is: ${env.BUILDVERSION}"
}
}
}
stage('Build Java Project') {
agent {
docker {
image 'tools/maven3/apache-maven-3.6.3-jdk1.11.34_101:1.1.4'
label 'generic-slave'
}
}
steps {
sh 'mvn --batch-mode -V -U -e clean deploy -P release -gs ../settings.xml -DskipTests'
sh 'echo the build $BUILDVERSION from $BRANCH_SCOPE has been successfully deployed on artifactory'
}
}
stage('Check npm Installation') {
agent {
docker {
image 'tools/nodejs/node-v22.10.0-linux-x64:1.0.0'
label 'generic-slave'
}
}
steps {
script {
def npmVersion = sh(script: 'npm -v', returnStdout: true).trim()
echo "npm version: ${npmVersion}"
}
}
}
stage('Build Angular Project') {
agent {
docker {
image 'tools/nodejs/node-v22.10.0-linux-x64:1.0.0'
label 'generic-slave'
}
}
steps {
script {
dir('angular-project-directory') {
sh '''
npm install
npm run build
'''
}
}
}
}
}
}
It doesn't work : see error below
ERROR: Attempted to execute a step that requires a node context while ‘agent none’ was specified. Be sure to specify your own ‘node { ... }’ blocks when using ‘agent none’.