jenkins pipline的命令如何查看语法

33 篇文章 0 订阅

https://www.jianshu.com/p/845f267aec52
我们常刚使用jenkins pipline的时候不知道语法命令怎么写,其实几个命令在jenkins上都有说明
在这里插入图片描述
在这里插入图片描述
点击生成流水线脚本即可,非常easy
在这里插入图片描述

pipline实例:

pipeline {
    agent any

    stages {
        stage('Hello') {
            steps {
                echo 'Hello World'
                git branch: 'dmp-2.5', credentialsId: 'at', url: 'http://(marked)/tfs/GS7/_git/BA-DMP'
            }
        }
        stage('build'){
            steps{
                sh "pwd"
                sh "mvn clean package -f dmp-datafactory/pom.xml"
            }
        }
    }
}
node {
    def mvnHome
    stage('Preparation') { // for display purposes
        cleanWs()
    }
    stage('Build') {
     //   writeFile encoding: 'utf-8', file: 'a.txt', text: 'haha'
        def envList=['oracle','ms','dm','my57','my8','pg','oscar','highgo','kingbase']
        for (String s : envList) {
            sh 'echo '+s
            if(!fileExists(s)){
                sh "mkdir "+s
                sh "cp /root/.jenkins/workspace/dmp2103/dmp-datafactory/target/dmp-datafactory.jar ./"+s
                sh "cp /root/.jenkins/workspace/dmp2103/dmp-datafactory/src/main/resources/*.properties ./"+s
                sh "cp /root/.jenkins/workspace/dmp2103/dmp-datafactory/src/main/resources/*.dmp ./"+s
                sh "cp -r /root/.jenkins/workspace/dmp2103/sqls/dbdir ./"+s
                sh "cp /root/.jenkins/workspace/dmp2103/dmp-datafactory/docker/docker-compose.yml ./"
                
            }
            
        }
        sh "mkdir premachine"
        sh "cp /root/.jenkins/workspace/dmp2103/PreposedMachine/target/preposed-machine.jar ./premachine/"
        
        withEnv(['JENKINS_NODE_COOKIE=background_job']){
            sh "docker-compose down"
            sh "docker-compose up -d"
        }
        
       
    }
    stage('Results') {
       echo "end"
    }
}

node {
    def mvnHome
    stage('cleanWorkspace') { 
        cleanWs()
    }
    stage('Preparation') { 
        cleanWs()
        // for display purposes
        // Get some code from a GitHub repository    feature/2103tablemerge    dmp-2103
       git branch: 'dmp-2103', credentialsId: 'at', url: 'http://tfs.inspur.com:8080/tfs/GS7/_git/BA-DMP'
        // Get the Maven tool.
        // ** NOTE: This 'M3' Maven tool must be configured
        // **       in the global configuration.
        mvnHome = tool 'M3'
    }
    stage('Build') {
        sh "pwd"
        
        timeout(30) {
     // Run the maven build
            withEnv(["MVN_HOME=$mvnHome"]) {
                if (isUnix()) {
                    sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore clean package -f ./dmp-datafactory/pom.xml'
                    sh '"$MVN_HOME/bin/mvn" -Dmaven.test.failure.ignore clean package -f ./PreposedMachine/pom.xml'
                } else {
                    bat(/"%MVN_HOME%\bin\mvn" -Dmaven.test.failure.ignore clean package -f dmp-datafactory\\pom.xml /)
                }
            }
        }       
    }
    stage('Results') {
        echo "finished"
      //  junit '**/target/surefire-reports/TEST-*.xml'
        archiveArtifacts 'dmp-datafactory/target/*.jar'
        archiveArtifacts 'PreposedMachine/target/*.jar'
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值