jenkins-pipeline

Continue Jenkins pipeline past failed stage

孤者浪人 提交于 2019-12-29 18:49:47
问题 I have a series of stages that perform quick checks. I want to perform them all, even if there are failures. For example: stage('one') { node { sh 'exit 0' } } stage('two') { node { sh 'exit 1' // failure } } stage('three') { node { sh 'exit 0' } } Stage two fails, so by default stage three is not executed. Ordinarily this would be a job for parallel , but I want to display them in the stage view. In the mock up below: Build #4 shows what normally happens. Job two fails so three does not run.

Continue Jenkins pipeline past failed stage

岁酱吖の 提交于 2019-12-29 18:49:09
问题 I have a series of stages that perform quick checks. I want to perform them all, even if there are failures. For example: stage('one') { node { sh 'exit 0' } } stage('two') { node { sh 'exit 1' // failure } } stage('three') { node { sh 'exit 0' } } Stage two fails, so by default stage three is not executed. Ordinarily this would be a job for parallel , but I want to display them in the stage view. In the mock up below: Build #4 shows what normally happens. Job two fails so three does not run.

Jenkins kubernetes plugin not working

你离开我真会死。 提交于 2019-12-29 06:23:17
问题 I am trying to setup Jenkins Dynamic slaves creation using jenkins-kubernetes plugin. My jenkins is running outside K8s Cluster. Link: https://github.com/jenkinsci/kubernetes-plugin My jenkins version is 2.60.2 and Kubernetes plugin version is 1.1.2 I followed the steps mention on the readme and successfully setup the connection. My setting looks like: And connection is successful. Then I created a job with pod template : Here starts the problem: 1. When I run this job initially it runs and

Load file with environment variables Jenkins Pipeline

本小妞迷上赌 提交于 2019-12-29 03:14:16
问题 I am doing a simple pipeline: Build -> Staging -> Production I need different environment variables for staging and production, so i am trying to source variables. sh 'source $JENKINS_HOME/.envvars/stacktest-staging.sh' But it returns Not found [Stack Test] Running shell script + source /var/jenkins_home/.envvars/stacktest-staging.sh /var/jenkins_home/workspace/Stack Test@tmp/durable-bcbe1515/script.sh: 2: /var/jenkins_home/workspace/Stack Test@tmp/durable-bcbe1515/script.sh: source: not

parse JSON in groovy to get values (python dict)

我们两清 提交于 2019-12-25 16:47:12
问题 I have a dictionary that I get as a python dictionary in groovy which I then assign to a variable x : def x = "{'JIRACHEF': 'PIBEP-2135', 'JIRADEPLOYER': 'PIBEP-2136', 'JIRASINGLEBUILD': 'PIBEP-2137'}" I want to parse the above and get values for : JIRACHEF JIRADEPLOYER JIRASINGLEBUILD whats the most elegant groovy way of doing it ? 回答1: You can use the LAX slurper (in recent versions of Groovy): import groovy.json.* def x = "{'JIRACHEF': 'PIBEP-2135', 'JIRADEPLOYER': 'PIBEP-2136',

Jenkins pipeline groovy.lang.MissingPropertyException

陌路散爱 提交于 2019-12-25 14:39:30
问题 I have simple groovy script that I'm using with Jenkins pipeline and fails on the git merge operation with kind of strange exception: The script: node("master") { ws(env.BUILD_NUMBER.toString()) { // workspace withCredentials([ [$class: 'UsernamePasswordBinding', credentialsId: 'bitbucket', variable: 'BITBUCKET_AUTH'], [$class: 'UsernamePasswordBinding', credentialsId: 'bitbucket-https', variable: 'BITBUCKET_HTTPS_AUTH'],]) { def applicationName = env.CUSTOMER_NAME def packageName = "no.bstcm

Run pipline on slave not master

时光毁灭记忆、已成空白 提交于 2019-12-25 09:05:46
问题 I am running Jenkins pipline (on Jenkins v2.58) and am trying to get the build to run on a slave not the master. Yet, whatever magic I try in the Jenkinsfile, Jenkins keeps running on master. How do I specify a slave executor? Here is my toy Jenkinsfile, if that helps: pipeline { agent { node { label='CentOS7' } } stages { stage('Creating tox virtual environment') { steps { sh 'uname -a' sh 'tox -v --recreate' } } } } 回答1: The right syntax appears to be: pipeline { agent { label 'CentOS7' }

Jenkins pipeline - getting a security error, how can I prevent the error from being raised?

扶醉桌前 提交于 2019-12-25 08:49:27
问题 I'm writing an Android build prcoess in Jenkins pipeline as a code. The relevant portion of the script is: def notifyStarted() { // send to Slack slackSend (channel: '#slack-test', color: 'warning', message: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})") } def get_current_time_date() { Date date = new Date(); // given date Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance calendar.setTime(date); // assigns calendar to given

Jenkins pipeline sh step not returning different status code [duplicate]

冷暖自知 提交于 2019-12-25 08:46:18
问题 This question already has answers here : Jenkins pipeline bubble up the shell exit code to fail the stage (2 answers) Closed 2 years ago . I have the following code inside the pipeline def deploy(branch='master', repo='xxx'){ if (env.BRANCH_NAME.trim() == branch) { def script = libraryResource 'build/package_indexes/python/build_push.sh' env.PYPI_REPO = repo sh script }else { echo "Not pushing to repo because branch is: "+env.BRANCH_NAME.trim()+" and not "+branch } } And the script looks like

Pushing a modified file in workspace to Github

房东的猫 提交于 2019-12-25 08:29:25
问题 As part of my Jenkins pipeline build I checkout my repo (which copies to my workspace I can see). I then modify a file in my workspace, which I then would like to push back up to my Github repo. I am just updating a version number in a podspec file. node { stage 'Update File' env.WORKSPACE = pwd() File file = new File("${env.WORKSPACE}/ios.podspec"); fileText = file.text; regex = "(spec.version\\s.*\$)"; fileText = fileText.replaceAll(regex, "spec.version = '${VERSION}'\n".trim()); file.write