Jenkins

authenticated urls

https://jenkins:glpat-nUhmY96Q28WTc3uApshM@gitlab.com/flipdare/device_info.git

Setup

automaton:F3JUW3jKpSQmJ
api token: 11ff2b879b5be09fb47a0b9f16ae5674f5
core token:  Sj3rgHuxV4TpTzFx1SIBoU1lS21E8ft8

Testing startup

/usr/bin/java -Djava.awt.headless=true -jar /usr/share/jenkins/jenkins.war --webroot=/var/cache/jenkins/war --httpPort=8080 --ajp13Port=-1

Install a plugin from the command line

  • As jenkins

    • Note, there is a a command in dev/tools/dev_jenkins_cli.sh to run cli commands.

        java -jar jenkins-cli.jar -s http://127.0.0.1:8080/   -auth automaton:F3JUW3jKpSQmJ  install-plugin disable-job-button:1.v9db_352414f90
      

Triggering builds

  • Can be done locally or remote.
  • use api-token for password

local

    /usr/bin/curl -k --user automaton:F3JUW3jKpSQmJ \
    http://127.0.0.1:8080/job/core/build

remotely

curl -X POST "https://repo.flipdare.com/buildByToken/buildWithParameters?" \
    --data "token=11ff2b879b5be09fb47a0b9f16ae5674f5" \
    --data "job=core"

Admin

systemctl enable jenkins
systemctl start jenkins
systemctl status jenkins
systemctl restart jenkins

Pipeline Setup

Create folder for workNew Item > Folder > "flipdare"
Go to folder and create pipelineNew Item > Pipline > "flipdare cache"
System environmentSystem Config > Environment Variables
SOURCE .bashrc

Sample Config

pipeline {
    agent any
    stages {
        stage('Checkout') {
            steps {
                checkout changelog: false, poll: false, scm: scmGit(branches: [[name:   'main']], extensions: [], userRemoteConfigs: [[credentialsId:     'jenkins_at_gitlab', name: 'origin', refspec: '+ refs/heads/main', url:     'git@gitlab.com:flipdare/device_info.git']])
            }
        }
    stage('Update local dependencies') {
        steps {
            sh ". ${env.SETUP};   /working/jenkins-admin/tools/jenkins/update-local-flutter-repos.sh `pwd`"
        }
    }
        stage('Fetch') {
            steps {
                sh ". ${env.SETUP}; dart pub get"
            }
        }
        stage('Test') {
            steps {
                sh ". ${env.SETUP}; flutter test --coverage"
            }
            post {
                always {
                    sh ". ${env.SETUP}; ${env.COVERAGE}"
                    recordCoverage(tools: [[parser: 'COBERTURA', pattern: 'coverage/    coverage.xml']])
                }
            }
        }
        stage('Run Analyzer') {
            steps {
                sh ". ${env.SETUP}; dart analyze"
            }
        }
    }
}