jenkins-pipeline

Jenkins Pipeline Git Push

馋奶兔 提交于 2021-02-04 18:58:48
问题 Is there as way to have a stage like so in a Jenkinsfile: stage('Create Branch & Push Branch') { steps { script { sh "git checkout -b release/${NEW_TAG}" sh "git push --set-upstream } } } Currently this leads to: git push --set-upstream origin release/v1.0.3 fatal: could not read Username for 'https://github.com': No such device or address script returned exit code 128 The repository was originally cloned earlier in the pipeline using: checkout poll: false, scm: [$class: 'GitSCM', branches: [

How to add timestamp for artifacts in Jenkins

这一生的挚爱 提交于 2021-02-04 16:40:50
问题 I have following Jenkisfile and I'm trying to upload the artifacts with a timestamp. import groovy.transform.Field @Field def timeStamp = Calendar.getInstance().getTime().format('YYYYMMdd-hhmmss',TimeZone.getTimeZone('CST')) node { stage('Creating some artifacts') { sh 'touch hello.txt hi.txt' } stage('Uploading artifacts') { def server = Artifactory.server ('art-1') def uploadSpec = """{ "files": [ { "pattern": "*.txt", "target": "repo1/Dev/${env.BUILD_NUMBER}/*.txt.${timeStamp}" } ] }"""

How to add timestamp for artifacts in Jenkins

送分小仙女□ 提交于 2021-02-04 16:40:22
问题 I have following Jenkisfile and I'm trying to upload the artifacts with a timestamp. import groovy.transform.Field @Field def timeStamp = Calendar.getInstance().getTime().format('YYYYMMdd-hhmmss',TimeZone.getTimeZone('CST')) node { stage('Creating some artifacts') { sh 'touch hello.txt hi.txt' } stage('Uploading artifacts') { def server = Artifactory.server ('art-1') def uploadSpec = """{ "files": [ { "pattern": "*.txt", "target": "repo1/Dev/${env.BUILD_NUMBER}/*.txt.${timeStamp}" } ] }"""

Jenkins does not show variables output in ECHO request in the groovy-pipeline

吃可爱长大的小学妹 提交于 2021-01-29 17:46:05
问题 just for example. I have this part of code in groovy-pipeline: echo "${GIT_BRANCH}" if ("${GIT_BRANCH}" == 'origin/mysuperbranch') { echo 'Branch name is "${GIT_BRANCH}". We can continue' } else { echo 'Branch name is "${GIT_BRANCH}". We can not continue' isValid = false return true } And let's look on output: [Pipeline] echo origin/mysuperbranch [Pipeline] echo Branch name is "${GIT_BRANCH}". We can continue Why in first output i can see what is in the variable ${GIT_BRANCH} , but in the

Sonarqube quality gate status check fail in Jenkins pipeline

假装没事ソ 提交于 2021-01-29 15:53:13
问题 Im new to jenkins pipeline scripting and sonarqube. it would be great if I can get some help with the question below. I want to fail the Jenkins declarative pipeline job when quality gate check fails. As per sonar documentation (https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-jenkins/#header-6), I tried with below two scenrions but both are seems not working and failing with errors. sonarqube analysis is working fine but it failing at QualityGate check. I created webhook in

Jenkins: Schedule Particular Stage with single pipeline

六月ゝ 毕业季﹏ 提交于 2021-01-29 15:24:57
问题 I have a single pipeline where it' declarative and I've several stages such as below triggers via webhook. I would like to execute and scheduled Stage B at a certain time which can also run without trigger via webhook. Clearly it needs to run when triggers via webhook and also run when it will be schedule. Can I handle this without creating seperate job or pipeline in Jenkins ? stage('A'){ when{ beforeAgent true expression{return env.GIT_BRANCH == "origin/development"} } steps{ script{ //Do

github-branch-source Jenkins integration fails running with error : stderr: fatal: Unable to find remote helper for 'https'

不问归期 提交于 2021-01-29 11:54:27
问题 Below is exception stacktrace which I see in Jenkins console log which is built/ rather kicked off automatically on push event. Push event to branch master Connecting to https://Gihub-private-repo/api/v3 using vinId/****** (vinId_pass) Obtained Jenkinsfile from 02f2d3a422dd46cb25bc7bad6c7f9ac1aedd58e7 Running in Durability level: MAX_SURVIVABILITY [Pipeline] Start of Pipeline [Pipeline] node Running on Jenkins in /home/jenkins2/.jenkins/workspace/teGhe_JenStUpdGhe_JenStUp_master [Pipeline] {

Selecting Quality Gate for SonarQube Analysis in Jenkinsfile

只愿长相守 提交于 2021-01-29 10:58:12
问题 I have a Jenkinsfile that, among other things, performs SonarQube analysis on my build and passes it through 'Quality Gate' stage. The analysis is placed on the SonarQube server where I can see all the details. The relevant pieces of code for the analysis and Quality gate are below (not mine, it is from documentation): stage('SonarCloud') { steps { withSonarQubeEnv('SonarQube') { sh 'mvn clean package sonar:sonar ' } } } stage("Quality Gate") { steps { timeout(time: 15, unit: 'MINUTES') { //

How to create and loop over an ArrayList of strings in Jenkins Groovy Pipeline

人盡茶涼 提交于 2021-01-29 10:19:08
问题 As stated in the title, I'm attempting to loop over an ArrayList of strings in a Jenkins Groovy Pipeline script (using scripted Pipeline syntax). Let me lay out the entire "problem" for you. I start with a string of filesystem locations separated by spaces: "/var/x /var/y /var/z ... " like so. I loop over this string adding each character to a temp string . And then when I reach a space, I add that temp string to the array and restart. Here's some code showing how I do this: def full_string =

How to pass parameter in curl while calling Jenkins job without using buildWithParameters

梦想与她 提交于 2021-01-29 09:50:14
问题 My Jenkins pipeline job is not parameterized, but while calling the job from a pipeline script I can provide parameters that are getting used inside my current job. I would like to pass those parameters from outside using a curl command. I tried the following options but am yet to be successful. curl -i -X POST 'https://<USERNAME>:<API_TOKEN>@JENKINS_URL/job/DS_JOB1/build?token=remotejob' --data-urlencode json='{"parameter": [{"PLATFORM":"Value1", "PROJECT": "Project_Type"}]}' This doesn't