in Education by
I have a Maven build of a Java application that runs successfully on either Linux or Windows by typing the identical command mvn install. However, using the Jenkinsfile method of setting up this build, on Linux that file needs to contain sh mvn install and on windows bat mvn install. If paths and tools are configured appropriately on Windows, log shows: [Pipeline] sh [C:\tools\jenkins\workspace\DSL\master] Running shell script sh: C:\tools\jenkins\workspace\DSL\master@tmp\durable-60527040\script.sh: command not found Is there any way for a single Jenkinsfile to allow building in both environments? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Pipeline scripts can contain groovy code, so branching with if is allowed. You can test your environment with System.properties['os.name'] and depending on the result, use sh or bat: node { def os = System.properties['os.name'].toLowerCase() echo "OS: ${os}" if (os.contains("linux")) { sh "mvn install" } else { bat "mvn install" } }

Related questions

0 votes
    How to share information between different build steps or stages in a Jenkins Job?...
asked Sep 14, 2021 in Technology by JackTerrance
0 votes
    Can you explain the Maven build lifecycle?...
asked Feb 5, 2023 in Technology by JackTerrance
0 votes
    Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have installed Docker Desktop for windows Docker version 18.09.2, build 6247962, and I'm not able ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    The open source _________ software is available for Unix, Linux, and Windows platforms. (a) Rserve (b) BServe ... of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    1.Which of the following software is not system software? a) Windows b)MS Word c)Linux d)DOS 2.Which of the ... Vista d) Windows NT Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    My question may be silly but I've been trying several ways and I still can't do what I want, i. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    How to download the Console log for a particular Jenkins build programmatically?...
asked Jul 17, 2021 in Technology by JackTerrance
0 votes
    We are trying to run automated tests using Microsoft Test Manager 2015. We've almost reached our goal. This ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I am creating a maven project from scratch, first just learn how to use maven. The main project contains ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I am creating a maven project from scratch, first just learn how to use maven. The main project contains ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    I'm trying to download a collection of files, but the instructions are for the command line in Unix. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Can we run Junits as a part of Jenkins job? (a) True (b) False I have been asked this question in ... Lifecycle & Annotations of Java Select the correct answer from above options...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    Can we run Junits as a part of Jenkins job? (a) True (b) False I have been asked this question ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    I'm developing a Nestjs micro-service and need to run the build in dist folder using below command and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
...