jenkins-pipeline

groovy + shell : Escaping characters

天大地大妈咪最大 提交于 2019-12-11 07:58:32
问题 I am using Jenkins Pipeline using Groovy sandbox. And i am trying to run a shell script in a groovy sh function. The original shell script is sed -i 's/sometext/'"${othertext}"'/' filename I am trying to replace a particular text with other text (taken dynamically). The script works fine when executed directly. But I want to use it in jenkins groovy sh function. sh(script: '<above shell script>', returnStdout:false) But there is a problem of escaping characters. I tried this way of escaping

Artifactory - Use Jenkins Pipeline script to upload

早过忘川 提交于 2019-12-11 07:42:22
问题 I'm trying to upload some binaries to Artifactory by using Jenkins Pipeline script. I used the same exemple from Artifactory documentation, but it doesn't work. I had the following error: hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.lang.String.upload() is applicable for argument types: (java.lang.String) values: [{ "files": [ .... There is another similar question but there is no response... pipeline { agent any environment { def server =

Jenkins Blueocean - same Jenkinsfile across multiple environments while passing different values of environment variables

廉价感情. 提交于 2019-12-11 07:39:24
问题 I do not want to put my environment variables in the source code, i know we can add variables in Jenkinsfile. How can i pass environment variable via the Jenkins job/UI while using Jenkins Blueocean? This needs to be done in a way so that I can use same Jenkinsfile across multiple environments while passing different values of environment variables. 来源: https://stackoverflow.com/questions/46291750/jenkins-blueocean-same-jenkinsfile-across-multiple-environments-while-passing

Suppress Pipeline Output in Jenkins file

て烟熏妆下的殇ゞ 提交于 2019-12-11 07:35:23
问题 When I run a build on my jenkins it always prints the pipeline while moving through the jenkins steps. The current output of the console: Build context: CI :clean :app:clean BUILD SUCCESSFUL in 22s 2 actionable tasks: 2 executed [Pipeline] script [Pipeline] { [Pipeline] properties [Pipeline] sh I want to see only the actual executions I've declared. The console ouput should look like Build context: CI :clean :app:clean BUILD SUCCESSFUL in 22s 2 actionable tasks: 2 executed 来源: https:/

WarningsPlugin not Collecting warnings from MSBuild

邮差的信 提交于 2019-12-11 07:32:26
问题 I am experimenting with a Multibranch job. Building the solution works, but parsing the warnings generated by the build fails. this is my Jenkinsfile: node { stage ('Checkout') { checkout scm } stage ('Build') { bat "\"${tool 'MSBuild VS2013'}\" Solution.sln /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}" } stage ('Warnings') { step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '',

Jenkins Permission Denied

你。 提交于 2019-12-11 07:29:23
问题 I'm sorry to come here and ask for that but I have read all the internet trying to find a solution but I still have this problem... I have installed successfully (let's start when I still had hope) jenkins to use it in our continous integration flow. I tried to start with a simple example like this one : pipeline { agent any stages { stage('Build') { steps { sh 'mvn -B -DskipTests clean package' } } } } But each time I start it, I have this error : sh: /var/lib/jenkins/workspace/Test@tmp

Need a working strategy to execute SQL scripts in Jenkins pipeline script

我怕爱的太早我们不能终老 提交于 2019-12-11 07:17:56
问题 As part of a Jenkins pipeline script, I need to execute some SQL scripts to initialize a database (mariadb). This job runs on a Jenkins slave that I own. I maintain the Jenkins master instance, but not the host it runs on. My first try was simply having inline code in the script to call "Sql.newInstance(...)" and "sql.execute(...)". This fails because the mariadb jar is not in the classpath. I then tried setting the CLASSPATH env var for the slave, to add the mariadb client jar to it, then

passing items in two lists simultaneoulsy in each loop Jenkinsfile

为君一笑 提交于 2019-12-11 06:46:20
问题 I have a list foo = ['tea',''sugar','milk'] and col = ['black','white','pink'] what I am trying to do is nested loop def foo = ['tea','sugar','milk'] def col = ['black','white','pink'] [foo, col].transpose().each { x, y -> sh """aws deploy push --application-name "${x}" --source "${y}" """ } Desired Result --application-name "tea" --source "black" --application-name "sugar" --source "white" --application-name "milk" --source "pink" the result I am getting [Pipeline] script [Pipeline] {

publishing to Artifactory from Jenkins Pipeline

萝らか妹 提交于 2019-12-11 06:08:23
问题 I'm trying to publish to an Artifactory (v4.5.1) instance using a Jenkins(v2.7) pipeline. An excerpt from my script is below. Problem seems to be that the "Artifactory" object is not recognized and is treated as a string. Can someone suggest what the problem might be? node { //error - "Artifactory" treated as String def server = Artifactory.server SERVER_ID def uploadSpec = """{ "files": [ { "pattern": "hello-pipeline/build/libs/*.jar", "target": "jenkins-local" } ] }""" def buildInfo1 =

Prompts in Jenkins

北战南征 提交于 2019-12-11 05:24:02
问题 I am trying to install software on centos 7 using ansible playbook through jenkins. I am trying to call ansible playbook from jenkins for installing the software. I am using vars_prompt in ansible playbook to pass some user-defined parameters, when i run the ansible playbook manually, it asks for prompts and runs successfully but when i build using jenkins it doesn't prompt for any inputs. Pipeline: node { ansiblePlaybook( installation: 'FirstAnsibleTest', inventory: '/etc/ansible/hosts',