Difference between revisions of "IT-SDK-Jenkins"
Jump to navigation
Jump to search
(→Coding) |
|||
| Line 22: | Line 22: | ||
</pre> | </pre> | ||
=Jenkenfiles= | =Jenkenfiles= | ||
| + | <pre class="code"> | ||
pipeline { | pipeline { | ||
agent { | agent { | ||
| Line 67: | Line 68: | ||
echo "Lib-Version: ${LIB_VERSION}" | echo "Lib-Version: ${LIB_VERSION}" | ||
} | } | ||
| + | </pre> | ||
Revision as of 16:40, 20 March 2020
Source
- src: https://jenkins.io/doc/book/pipeline/syntax/
- src: https://jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
Coding
def username = 'Jenkins'
echo 'Hello Mr. ${username}'
echo "I said, Hello Mr. ${username}"
...
Hello Mr. ${username}
I said, Hello Mr. Jenkins
environment {
APP = "${env.APP}-${env.BRANCH_NAME}"
}
steps {
sh 'echo "Name=${APP}"'
echo "Running ${APP} on ${env.APP}"
}
Jenkenfiles
pipeline {
agent {
label 'nodejs10'
}
environment {
APP = 'application'
VERSION = 't.b.d.'
}
options {
buildDiscarder(logRotator(numToKeepStr: '15'))
}
stages {
stage('Environment') {
steps {
echo "Applacation: ${APP} or ${env.APP}"
sh 'echo "Lib-Version: ${LIB_VERSION}"'
echo "##################################"
setVersion()
echo "##################################"
script {
env.LIB_VERSION = "newValue"
}
sh 'export AWESOME_FILE=$AWESOME_BUILD/the_file'
sh 'echo $AWESOME_FILE' // But it won't show up here!
// However, in a single sh command it will work.
sh '''
export AWESOME_FILE=$AWESOME_BUILD/the_file
echo $AWESOME_FILE
'''
}
}
stage('Build-Angular') {
steps {
//build job: 'test', parameters:[string(name: 'LIB_VERSION', value: "${LIB_VERSION}")], wait: false
}
}
}
}
def setVersion() {
LIB_VERSION = 'Samer'
echo "Lib-Version: ${LIB_VERSION}"
}