Notifications
Clear all
Topic starter
07/10/2022 6:34 pm
You're a DevOps engineer in charge of your team's Jenkins server. You have a particular stage in your pipeline that you want to run on a particular build node. You have to have Apache installed on this node.
Assuming the node has been appropriately labeled, "apache", how would you ensure this stage ran on that node?
- A . apache agent
- B . agent { label 'apache' }
- C . agent( 'apache' )
- D . apache' { agent }
Suggested Answer: B
Explanation:
Example: stage('deploy') { agent { label 'apache' } steps { sh "if ![ -d '/var/www/html/rectangles/all/${env.BRANCH_NAME}' ]; then mkdir /var/www/html/rectangles/all/${env.BRANCH_NAME}; fi" sh "cp dist/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar /var/www/html/rectangles/all/${env.BRANCH_NAME}/" }
Explanation:
Example: stage('deploy') { agent { label 'apache' } steps { sh "if ![ -d '/var/www/html/rectangles/all/${env.BRANCH_NAME}' ]; then mkdir /var/www/html/rectangles/all/${env.BRANCH_NAME}; fi" sh "cp dist/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar /var/www/html/rectangles/all/${env.BRANCH_NAME}/" }