jenkins-pipeline

get details of source repository from Jenkinsfile

ⅰ亾dé卋堺 提交于 2019-12-11 14:50:08
问题 A Jenkinsfile uses a checkout scm command to retrieve the most recent commit from a linked Bitbucket respository. What specific syntax needs to be added to the Jenkinsfile in order for the Jenkinsfile to be able to extract the repositorySlug , and projectKey from the source repository as variables, and then print out those variables as console output?** Sample Jenkinsfile: I tried to incorporate ideas from the Jenkins Pipeline SCM Step Documentation in the following example Jenkinsfile whose

Jenkins pipeline Output from aws to for loop

倾然丶 夕夏残阳落幕 提交于 2019-12-11 14:19:34
问题 I have a jenkins pipeline as below. I need the output from aws which returns multiple items to be split and used as individual items in a for loop which can be used to perform another action i have tried def ASG_GROUP_NAME toString() as it seems it's not returning as a full string but with no luck def ASG_GROUP_NAME = sh (script: """ aws autoscaling describe-auto-scaling-groups --region ${AWS_REGION} --query "AutoScalingGroups[? Tags[? Key=='Environment' && Value=='${ENVIRONMENT}']] | [? Tags

GIT URL in Jenkins pipeline

故事扮演 提交于 2019-12-11 14:03:54
问题 I am trying to parameterize a Jenkins pipeline. The only input parameter will be GITHUB_URL. I have a Jenkinsfile as a part of the repo. I want to use this variable (defined as parameter) in my pipeline configuration as "Repository URL". How can I access the parameter ? I have tried $GITHUB_URL, ${GITHUB_URL} and ${params.GITHUB_URL}. No luck Any other suggestions? 回答1: Because you are telling you have a jenkinsfile inside your git repo I suppose you do not mean that you want to call a

Anaconda in Jenkinsfile

可紊 提交于 2019-12-11 13:47:25
问题 Since the tests we are running are getting longer and longer, I thought it would be a good idea to switch from Travis CI to Jenkins (on my local computer). Setting up Jenkins was relatively straightforward, however getting my Jenkinsfile to 'work' not so much. I am trying to download miniconda -> install miniconda -> install an environment -> activate the environment -> run commands from that environment. This is what I got so far: environment { PATH = "$WORKSPACE/miniconda/bin:$PATH" }

Return a String from a Windows Batch file

谁都会走 提交于 2019-12-11 11:49:30
问题 I want to find the target branch when a pull request is submitted on GitHub, in my Jenkins pipeline. To achieve this I am doing the following: I am invoking a windows batch file from my Jenkinsfile, which in turn invokes a nodejs script. This script internally invokes GitHub APIs to get the target branch which is to be set on some variable in Jenkinsfile(code snippet given below): Jenkinsfile env.TARGET_BRANCH = bat "GetTargetBranchFromGit.bat ${env.BRANCH_NAME}" BatchFile: node

How to run jenkins pipeline job with docker commands in stand alone Jenkins

与世无争的帅哥 提交于 2019-12-11 10:59:52
问题 I have a jenkins pipeline script which creates the Docker image and deploys it to the docker hub. I have installed the docker plugin but it complains about "docker command not found" . I am not sure if I need to install docker in the same machine or something else need to happen? 回答1: Yes you have to install docker on the slave machine which is running that pipeline script of docker plugin. I would suggest adding a label docker to the slave that has docker installed and then use the pipeline

How to safe guard against broken jenkinsfiles causing pipelines to run indefinitely?

非 Y 不嫁゛ 提交于 2019-12-11 09:05:43
问题 I have my repo getting polled every 5 mins. But I found that if the jenkinsfile is totally broken the pipeline will fail with "This stage has no steps". Then every 5 mins it will retry it and keep failing. How do I safe guard against this? Can I set a threshold somewhere so if this happens it doesn't churn forever? 回答1: If you are using scm polling, it should only build if there are changes. Sounds like you may be building on a cron schedule. Here is the different syntax for each in a

Jenkinsfile cifsPublisher not copying right files using wildcards

孤街醉人 提交于 2019-12-11 08:52:57
问题 In my Jenkins scripted pipeline I'm trying to copy files to a remote Windows Share using cifsPublisher As documented here I should use myPrj/deploy/**/* as sourceFiles pattern but files I expect to be copied are not. This is my Jenkinsfile step: stage('Save WAR'){ // sh 'ls -laR ./myPrj/deploy/' // cifsPublisher(publishers: [[ configName: 'myConfig', transfers: [[cleanRemote: false, excludes: '', flatten: false, makeEmptyDirs: true, noDefaultExcludes: false, patternSeparator: '',

Why SONAR fails at waitForQualityGate() with error 401?

房东的猫 提交于 2019-12-11 08:39:59
问题 Using pipeline code, stage ('SonarQube') { withSonarQubeEnv { dir ('mydir/') { sh "'${mvnHome}/bin/mvn' sonar:sonar -Dsonar.login=something -Dsonar.projectKey=someproj -Dsonar.projectName=somename" } } timeout(time: 15, unit: 'MINUTES') { def qg = waitForQualityGate() if (qg.status != 'OK') { error "Pipeline aborted due to quality gate failure: ${qg.status}" } } Which progresses crrectly over the first mvn section and breaks on waitforqualitygate() operation: org.sonarqube.ws.client

When executing jobs in Jenkins pipeline and a job is failed at night how do you resume it in the same night?

白昼怎懂夜的黑 提交于 2019-12-11 08:35:13
问题 When executing selenium jobs in Jenkins pipeline and a job is failed at night how do you resume it in the same night? 回答1: You can use Naginator plugin to achieve your intended behavior. Configure it as follows: Install the plugin -> check the Post-Build action "Retry build after failure" on your project's configuration page. If the build fails, it will be rescheduled to run again after the time you specified. You can choose how many times to retry running the job. For each consecutive