jenkins-pipeline

How to pip install in a docker image with a jenkins pipline step?

心不动则不痛 提交于 2020-01-02 08:38:13
问题 I have this Dockerfile : FROM python:3.7 CMD ["/bin/bash"] and this Jenkinsfile : pipeline { agent { dockerfile { filename 'Dockerfile' } } stages { stage('Install') { steps { sh 'pip install --upgrade pip' } } } This causes the following error: The directory '/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory

Jenkins Pipeline Across Multiple Docker Images

耗尽温柔 提交于 2020-01-02 06:07:29
问题 Using a declarative pipeline in Jenkins, how do I run stages across multiple versions of a docker image. I want to execute the following jenkinsfile on python 2.7, 3.5, and 3.6. Below is a pipeline file for building and testing a python project in a docker container pipeline { agent { docker { image 'python:2.7.14' } } stages { stage('Build') { steps { sh 'pip install pipenv' sh 'pipenv install --dev' } } stage('Test') { steps { sh 'pipenv run pytest --junitxml=TestResults.xml' } } } post {

Jenkins Pipeline Across Multiple Docker Images

我与影子孤独终老i 提交于 2020-01-02 06:03:47
问题 Using a declarative pipeline in Jenkins, how do I run stages across multiple versions of a docker image. I want to execute the following jenkinsfile on python 2.7, 3.5, and 3.6. Below is a pipeline file for building and testing a python project in a docker container pipeline { agent { docker { image 'python:2.7.14' } } stages { stage('Build') { steps { sh 'pip install pipenv' sh 'pipenv install --dev' } } stage('Test') { steps { sh 'pipenv run pytest --junitxml=TestResults.xml' } } } post {

How to checkout ssh remote in github organization Jenkins workflow and use ssh credentials in Jenkinsfile

心已入冬 提交于 2020-01-02 02:55:09
问题 I have a Github Organisation item in jenkins. On the root of my repository, my Jenkinsfile looks something like this: node { def jenkinsCredsId = 'xxxxxxxx-yyyy-zzzz-aaaa-bbbbbbbbbbbb' stage 'Checkout' checkout scm // I also tried the following: // checkout scm: [$class: 'GitSCM', source: 'ssh://git@github.com:MY_ORGANISATION/jenkins-testing-temp.git', clean: true, credentialsId: jenkinsCredsId] stage 'Build' // generate some artefact (dist.zip) stage 'Release' sshagent([jenkinsCredsId]) { sh

How to get the output of a shell script in a Jenkinsfile?

岁酱吖の 提交于 2020-01-02 02:40:11
问题 In a Jenkinsfile Groovy script stage, say I want to issue a linux command that outputs rows and columns of strings, and want to get the nth column in the output of a certain row. An example of such command is "ls -al." So I do this correct? stage("Get dir size") { sh returnStatus: true, script: ''' LINE=`ls -al | grep some_dir` IFS=" " read -ra COLS <<< $LINE echo ${COLS[4]} ''' /* I want to use the value of ${COL[4]} after above block */ } But how do I get the value of essentially ${COL[4]},

jenkins pipeline: multiline shell commands with pipe

笑着哭i 提交于 2020-01-02 00:11:25
问题 I am trying to create a Jenkins pipeline where I need to execute multiple shell commands and use the result of one command in the next command or so. I found that wrapping the commands in a pair of three single quotes ''' can accomplish the same. However, I am facing issues while using pipe to feed output of one command to another command. For example stage('Test') { sh ''' echo "Executing Tests" URL=`curl -s "http://localhost:4040/api/tunnels/command_line" | jq -r '.public_url'` echo $URL

How to use jenkins version number plugin in Jenkinsfile?

橙三吉。 提交于 2020-01-01 18:43:06
问题 Trying this step in Jenkinsfile with "version number plugin" installed: stage("Build") { echo "Building..." TAG = ${BUILD_DATE_FORMATTED, "yyyyMMdd"}-develop-${BUILDS_TODAY} sh "docker build -t $IMAGE:$TAG ." } And getting this error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 15: unexpected token: BUILD_DATE_FORMATTED @ line 15, column 15. TAG=${BUILD_DATE_FORMATTED, "yyyy-MM-dd"}-develop-${BUILDS_TODAY} ^ 1 error What is correct way to

jenkins fails after checkout with no error

北城以北 提交于 2020-01-01 15:07:42
问题 My pipeline fails periodically and this is all I see: ... [Pipeline] cleanWs [WS-CLEANUP] Deleting project workspace... [WS-CLEANUP] Deferred wipeout is used... [WS-CLEANUP] done [Pipeline] checkout Cloning the remote Git repository Cloning repository https://bitbucket.org/myteam/myrepo.git > git init C:\WS\master_sdfsdfsdf # timeout=10 Fetching upstream changes from https://bitbucket.org/myteam/myrepo.git > git --version # timeout=10 using GIT_ASKPASS to set credentials mycreds > git fetch -

How to add git credentials to the build so it would be able to be used within a shell code?

笑着哭i 提交于 2020-01-01 10:11:51
问题 I've wrote the following Jenkinsfile: node("master") { def artifactory_creds = 'XXXXXXX' def git_creds = 'XXXXXXX' java = docker.image('openjdk:8-jdk') java.pull() java.inside("-u root --ulimit core=99999999") { withCredentials([ // Use Jenkins credentials ID of artifactory [$class: 'UsernamePasswordMultiBinding', credentialsId: artifactory_creds, usernameVariable: 'A_USER', passwordVariable: 'A_PASS'], [$class: 'UsernamePasswordMultiBinding', credentialsId: git_creds, usernameVariable: 'G

How to add git credentials to the build so it would be able to be used within a shell code?

纵饮孤独 提交于 2020-01-01 10:11:08
问题 I've wrote the following Jenkinsfile: node("master") { def artifactory_creds = 'XXXXXXX' def git_creds = 'XXXXXXX' java = docker.image('openjdk:8-jdk') java.pull() java.inside("-u root --ulimit core=99999999") { withCredentials([ // Use Jenkins credentials ID of artifactory [$class: 'UsernamePasswordMultiBinding', credentialsId: artifactory_creds, usernameVariable: 'A_USER', passwordVariable: 'A_PASS'], [$class: 'UsernamePasswordMultiBinding', credentialsId: git_creds, usernameVariable: 'G